@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Personal Expenses',
theme: ThemeData(
brightness: Brightness.light,
primaryColor: Colors.lightGreen[800],
primarySwatch: Colors.amber,
errorColor: Colors.red,
accentColor: Colors.cyan[600],
fontFamily: 'Quicksand',
textTheme: ThemeData.light().textTheme.copyWith(
title: TextStyle(
fontFamily: 'Quicksand',
backgroundColor: Colors.grey,
fontSize: 18,
),
),
appBarTheme: AppBarTheme(
textTheme: ThemeData.light().textTheme.copyWith(
title: TextStyle(
fontFamily: 'OpenSans',
fontSize: 20,
fontWeight: FontWeight.bold,
fontStyle: FontStyle.italic),
button: TextStyle(color: Colors.white),
),
)
),
home: MyHomePage(),
);
}
例如,要在 Button 上应用主题,我正在这样做,但主题不适用于它
FlatButton(
color: Colors.white,
textColor: Theme.of(context).textTheme.button.color,
onPressed: _presentDatePicker,
child: Text(
'Choose Date',
style: TextStyle(fontWeight: FontWeight.bold),
),
)