Search code examples
dartflutterflutter-layoutflutter-dependencies

How to change status bar color in Flutter?


I am trying to change the status bar color to white. I found this pub on flutter. I tried to use the example code on my dart files.


Solution

  • Works totally fine in my app

    import 'package:flutter_statusbarcolor/flutter_statusbarcolor.dart';
    
    void main() => runApp(new MyApp());
    
    class MyApp extends StatelessWidget {
      @override
      Widget build(BuildContext context) {
        FlutterStatusbarcolor.setStatusBarColor(Colors.white);
        return MaterialApp(
          title: app_title,
          theme: ThemeData(
            primarySwatch: Colors.blue,
          ),
          home: HomePage(title: home_title),
        );
      }
    }
    

    UPD: Recommended solution (Flutter 2.0 and above)

    SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle(
      statusBarColor: Colors.white
    ));
    

    Note: This package is not compatible with Flutter 3.0 or above [1]: https://pub.dev/packages/flutter_statusbarcolor