I’ve forced my app to use dark theme
darkTheme: ThemeData( brightness: Brightness.dark, useMaterial3: true, colorSchemeSeed: colorSeed, ), // Always dark mode. themeMode: ThemeMode.dark,
It works greatly on iOS, but on Android, the system navigation bar is still in light mode.
2
I believe this is the correct default behavior: the system keeps the navigation bar colors in contrast with the app content.
However, you can control the status bar and navigation bar colors using SystemUIOverlayStyle.
SystemUIOverlayStyle
This style can be set either using SystemChrome:
SystemChrome
SystemChrome.setSystemUIOverlayStyle( // This is an example. You can create a custom style with different colors SystemUiOverlayStyle.dark, );
or by setting the systemOverlayStyle property on an AppBar:
systemOverlayStyle
AppBar
// In the `build` method in your page: return Scaffold( appBar: AppBar( title: Text('title'), systemOverlayStyle: SystemUiOverlayStyle.dark, ), body: Center(child: Text('Page content')), );
You can change System navigation bar color with SystemChrome.setSystemUIOverlayStyle.
SystemChrome.setSystemUIOverlayStyle
Just add this code in your main function and your whole app’s navigation bar color change to black.
main
void main() { WidgetsFlutterBinding.ensureInitialized(); SystemChrome.setSystemUIOverlayStyle(const SystemUiOverlayStyle( systemNavigationBarColor: Colors.black, systemNavigationBarDividerColor: Colors.transparent, )); runApp(const MyApp()); }
Or you can set it to dark:
void main() { WidgetsFlutterBinding.ensureInitialized(); SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle.dark); runApp(const MyApp()); }
If you only want to change the navigation bar colors for a single screen, you can do so by setting the SystemUiOverlayStyle directly in the appBar of that screen:
SystemUiOverlayStyle
appBar
appBar: AppBar( systemOverlayStyle: SystemUiOverlayStyle( systemNavigationBarColor: Colors.white, ), ),
Click here to cancel reply.
2
Answers
I believe this is the correct default behavior: the system keeps the navigation bar colors in contrast with the app content.
However, you can control the status bar and navigation bar colors using
SystemUIOverlayStyle
.This style can be set either using
SystemChrome
:or by setting the
systemOverlayStyle
property on anAppBar
:You can change System navigation bar color with
SystemChrome.setSystemUIOverlayStyle
.Just add this code in your
main
function and your whole app’s navigation bar color change to black.Or you can set it to dark:
If you only want to change the navigation bar colors for a single screen, you can do so by setting the
SystemUiOverlayStyle
directly in theappBar
of that screen: