Transparent status bar in flutter

前端 未结 5 1254
时光取名叫无心
时光取名叫无心 2021-01-31 11:23

I just started using flutter and android studio and I was wondering if there’s a way to make a transparent status bar like the pic on Android (no transition from the status bar

5条回答
  •  春和景丽
    2021-01-31 11:58

    Yes, this is possible on Android.

    In order to do that, you can use SystemChrome. That class provides a setSystemUIOverlayStyle method and you can use it like this:

    import 'package:flutter/services.dart';
    
    SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle(statusBarColor: Colors.transparent));
    

    Keep in mind that this will only work for Android versions equal to or greater than Android M and that you will need to draw below the status bar by avoiding the padding that a Scaffold adds automatically. You can do that by using:

    ...body: SafeArea(top: false, child: ...
    

提交回复
热议问题