I am able to set the background color of AppBar to Colors.amber. This automatically sets the text color to Black. I am aware of the accessibility i
In the widget that runs when you first call main.dart file, you can add a named parameter theme which enables you to add global styles
In the build method of the widget,
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
theme: _buildLightTheme(),
title: 'title of app',
home: LoginPage(app: app),
initialRoute: '/login',
routes: {
"/login": (BuildContext context) => LoginPage(app: app,)
});
}
Here I have created a separate method for my themes called _buildLightTheme
ThemeData _buildLightTheme() {
final ThemeData base = ThemeData.light();
return base.copyWith(
accentColor: kUndaGreen,
scaffoldBackgroundColor: kUndaWhite,
cardColor: Colors.white,
textSelectionColor: Colors.amberAccent,
errorColor: Colors.green,
textSelectionHandleColor: Colors.black,
appBarTheme:_appBarTheme()
);
}
For the appBarTheme I have a separate method _appBarTheme
AppBarTheme _appBarTheme(){
return AppBarTheme(
elevation: 0.0,
color: kUndaGreen,
iconTheme: IconThemeData(
color: Colors.white,
),);
}