做到这一点的方法之一是定义
buttonTheme在
theme中
MaterialApp:
例如:
void main() { runApp(MaterialApp( home: Home(), theme: ThemeData( accentColor: Colors.redAccent, buttonTheme: ButtonThemeData(buttonColor: Colors.blueAccent,shape: RoundedRectangleBorder(),textTheme: ButtonTextTheme.accent,.... )), ));}class Home extends StatelessWidget { Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text("Button Theme"), backgroundColor: Colors.green), body: Center( child: RaisedButton( //Button Color is as define in theme onPressed: () {}, child: Text("Send"), //Text Color as define in theme )), ); }}与此相关的所有在此下定义的按钮
MaterialApp都将采用此主题样式。
文字颜色将是我
accentColor定义的中的
ThemeData定义,
textTheme:ButtonTextTheme.accent因此它将选择
accentColor
按中定义的按钮选择主题样式
theme



