Themes Styles, Themes, and InheritedWidget

This lesson is available for PRO members or as a single course purchase. Sign-in and choose a plan below.

Example Code

file_type_dartlang main.dart
class MyApp extends StatelessWidget {
 @override
 Widget build(BuildContext context) {
   return MaterialApp(

     theme: ThemeData(
       brightness: Brightness.light,
       primaryColor: Colors.lightGreen,
       textTheme: TextTheme(
         body1: TextStyle(color: Colors.red, fontSize: 30),
         headline: TextStyle(color: Colors.blue, fontSize: 70)
       )
     ),

     home: HomeScreen(),
   );
 }
}

class HomeScreen extends StatelessWidget {
 @override
 Widget build(BuildContext context) {
   return Scaffold(
     appBar: AppBar(),
     body: Center(
       child: Text('Hello World', style: Theme.of(context).textTheme.headline,),
     )
   );
 }
}

Questions?

Ask questions via GitHub below OR chat on Slack #questions