Search code examples
flutterstatusbar

Flutter status bar color with SafeArea in iOS


I am using the following code for coloring the status bar in flutter.

void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
SystemChrome.setPreferredOrientations(
    [DeviceOrientation.portraitUp, DeviceOrientation.portraitDown]);
return AnnotatedRegion<SystemUiOverlayStyle>(
  value: SystemUiOverlayStyle(statusBarColor: Colors.blue),
  child: MaterialApp(
    title: 'My App',
    theme: ThemeData(
        primarySwatch: Colors.blue),
    home: MyHomeScreen(),
    navigatorKey: navigatorKey,
  ),
);
}}

class MyHomeScreen extends StatelessWidget {
const MyHomeScreen({Key key}) : super(key: key);

@override
Widget build(BuildContext context) {
return Scaffold(
  body: SafeArea(
    child: Header(), // my own custom header
  ),
);
}
}

With the above code I am getting the desired result in Android but in iOS the status bar is still showing in white color. I have tried this link but I am not getting the desired solution for iOS.


Solution

  • I had also same issue. i found solution with this.

    try that package.