/////////////////////////////// theme switcher example ///////////////////////////// ////////////////////main.dart import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import './theme_model.dart'; void main() => runApp(ChangeNotifierProvider( create: (_) => ThemeModel(), child: MyApp())); class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( debugShowCheckedModeBanner: false, title: 'Flutter Demo', theme: Provider.of(context).currentTheme, home: MyHomePage(title: 'Theme switch'),);}} class MyHomePage extends StatelessWidget{ final String title; MyHomePage({this.title}); Widget build(BuildContext context){ return Scaffold( appBar: AppBar( title: Text(title)), body: Center( child:RaisedButton(child: Text("Change Theme"), onPressed:(){ Provider.of(context, listen: false).toggleTheme();})));}} ////////////////////constant.dart import 'package:flutter/material.dart'; const Color kPrimaryBackground = Color(0xff1f655d); const Color kAccentBackground = Color(0xff2c8d82); const Color kfloatingColor = Color(0xff35c168); const Color kUserLabelColor = Color(0xff40bf7a); const Color kLineColor = Color(0xff45827b); const List contextMenu = ["Settings", "About"]; FloatingActionButtonThemeData fabTheme = FloatingActionButtonThemeData( backgroundColor: kfloatingColor, foregroundColor: Colors.white, ); ThemeData darkTheme = ThemeData.dark().copyWith( primaryColor: Color(0xff1f655d), accentColor: Color(0xff40bf7a), textTheme: TextTheme( headline6: TextStyle(color: Color(0xff40bf7a)), subtitle2: TextStyle(color: Colors.white), subtitle1: TextStyle(color: Color(0xff40bf7a))), appBarTheme: AppBarTheme(color: Color(0xff1f655d))); ThemeData lightTheme = ThemeData.light().copyWith( primaryColor: Color(0xfff5f5f5), accentColor: Color(0xff40bf7a), textTheme: TextTheme( headline6: TextStyle(color: Colors.black54), subtitle2: TextStyle(color: Colors.grey), subtitle1: TextStyle(color: Colors.white)), appBarTheme: AppBarTheme( color: Color(0xff1f655d), actionsIconTheme: IconThemeData(color: Colors.white))); enum ThemeType { Light, Dark } ///////////////////theme_model.dart