Can someone help to point how do we define base theme for button and use it on every button? Everywhere I look only found textTheme but not buttonTheme
One way to do it is to Define buttonTheme in theme in MaterialApp:
E.g:
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
)),
);
}
}
with this all the Buttons defined under this MaterialAppwill Carry this Theme Style.
Text Color will be the accentColor define in the ThemeData as i have defined textTheme: ButtonTextTheme.accent so it will Pick accentColor
Button picking Theme Style As Defined in theme