HomeiOS Developmentandroid - Flutter : the way to make one of many screens...

android – Flutter : the way to make one of many screens of the app be capable of present even when cellphone is locked


App with two screens/stateful widgets, and the second display to have the ability to present even when the cellphone is locked, not the entire app, for instance Alarm app the place the Alarm alert display can showup even when cellphone is locked and consumer willbe capable of carry out actions on that display whereas the cellphone being locked, or any messenger or calling app with callScreen, consumer will see that display and be capable of carry out settle for/reject with out unlocking cellphone.


        void important() {
          runApp(const MyApp());
        }
        
        class MyApp extends StatelessWidget {
          const MyApp({tremendous.key});
        
          @override
          Widget construct(BuildContext context) {
            return MaterialApp(
              title: 'MAIN SCREEN HOME',
              theme: ThemeData(
                primarySwatch: Colours.blue,
              ),
              house: const MyHomePage(title: 'FIRST SCREEN'),
            );
          }
        }
        
        class MyHomePage extends StatefulWidget {
          const MyHomePage({tremendous.key, required this.title});
        
          last String title;
        
          @override
          State<MyHomePage> createState() => _MyHomePageState();
        }
        
        class _MyHomePageState extends State<MyHomePage> {
        
          @override
          Widget construct(BuildContext context) {
            return Scaffold(
              appBar: AppBar(
                title: Textual content(widget.title),
              ),
              physique: Heart(
                baby:  TextButton(baby: const Textual content('GO TO SECOND SCREEN SCREEN'),onPressed: (){
                  Navigator.push(context, MaterialPageRoute(builder:(context) => const SecondScreen()));
                }, ),
        
              ),
            );
          }
        }
        
        
        
        
        
        
        class SecondScreen extends StatefulWidget {
          const SecondScreen({Key? key}) : tremendous(key: key);
        
          @override
          State<SecondScreen> createState() => _SecondScreenState();
        }
        
        class _SecondScreenState extends State<SecondScreen> {
          @override
            Widget construct(BuildContext context) {
              return Scaffold(
                appBar: AppBar(
                  title: Textual content('SECOND SCREEN'),
                ),
                physique: const Heart(
                  baby:  Textual content('THIS IS SECOND SCREEN THAT SHOULD BE ACCESSIBLE EVEN WHEN PHONE IS LOCKED'),
                ),
              );
            }
        }

MyHomePage is the touchdown web page, when consumer is on this display, and cellphone is locked, then fi we attempt to unlock it, it requires unlocking cellphone, which is regular

but when we navigate to SecondScreen by handbook click on of the button on the primary display, or with any automated triggers within the background, the second display ought to be seen even when the cellphone is locked, just like how name screens work on regular calling app or whatsapp or another app that has calling characteristic, solely that decision display is seen,

I attempted inserting these attributes in androidManifest file of the one exercise,

android:showWhenLocked="true" android:turnScreenOn="true"

however your complete app is turning into accessible, required behaviour is that the one SecondScreen to be accessible on locked screens, the remainder ought to require unlocking cellphone

I additionally tried creating one other factor below in AndroidManifest.xml file however undecided if its proper in Flutter as i learn its single exercise circulation,

If any of you tried this, or comparable, please share your ideas.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments