Open your IDE and run the app. Let's start theming the e-commerce screen by adding a theme to your MaterialApp widget:
- Open main.dart and add the following code:
class StaticApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData(
brightness: Brightness.dark,
primaryColor: Colors.green,
),
home: ECommerceScreen(),
);
}
}
- Now that the Theme has been declared, the rest of the recipe will about deleting code so that the theme traverses down to the appropriate widgets.
- In the Scaffold of the EcommerceScreen class, delete the property and value for backgroundColor. In the _buildAppBar method, also delete these two lines:
backgroundColor: Colors.purpleAccent,
elevation: 0,
When you hot reload, the AppBar will be green, respecting the primaryColor property of the app's theme.
- The toggle bar could use a bit...