How to hide Android StatusBar in Flutter

后端 未结 10 1349
遥遥无期
遥遥无期 2020-12-01 03:22

How to hide the Android Status Bar in a Flutter App?

相关标签:
10条回答
  • 2020-12-01 03:59

    You can use SystemChrome.setEnabledSystemUIOverlays([]) to hide and SystemChrome.setEnabledSystemUIOverlays(SystemUiOverlay.values) to bring it back again.

    However, there will be slight grey area and there is not fix for this as of right now. When status bar is hidden, app bar's height remains the same.

    See the github issue: https://github.com/flutter/flutter/issues/14432

    0 讨论(0)
  • 2020-12-01 04:00

    SystemChrome.setEnabledSystemUIOverlays([]) should do what you want.

    You can bring it back with SystemChrome.setEnabledSystemUIOverlays(SystemUiOverlay.values).

    Import it using

    import 'package:flutter/services.dart';
    
    0 讨论(0)
  • 2020-12-01 04:00
     body: MyAppBody(),
    

    CHANGE THIS TO

    body: SafeArea(child: MyAppBody()),
    

    0 讨论(0)
  • 2020-12-01 04:04

    i: To hide status bar: SystemChrome.setEnabledSystemUIOverlays([SystemUiOverlay.bottom]);

    ii: Use SafeArea Widget it will make sure that your app does not take status bar area.

    @override
    Widget build(BuildContext context) {
        return Scaffold(
          body: SafeArea(
              child: Container(
                child: Text('Do not take status bar area on screen!'),
              ),
            );
    }
    
    0 讨论(0)
提交回复
热议问题