Monday 4 January 2021

How to automatically hide the status bar in flutter after a few seconds?

I want to automatically hide the status bar after 3 seconds of scrolling it down.

currently, I'm doing this.

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  @override
  void initState() {
    super.initState();
    Timer.periodic(const Duration(seconds: 3), (timer) {
      SystemChrome.setEnabledSystemUIOverlays([SystemUiOverlay.bottom]);
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: HomeScreen();
    );
  }
}

I want the timer to begin as soon as the user scrolls the the status bar.

Is there any better way to do that?



from How to automatically hide the status bar in flutter after a few seconds?

No comments:

Post a Comment