class SubmitButton extends StatelessWidget {
final String title;
final Function onPressed;
const SubmitButton({Key key, this.title, this.onPressed}) : super(key: key);
@override
Widget build(BuildContext context) {
return Theme(
data: ThemeData(
buttonTheme: const ButtonThemeData(
colorScheme: ColorScheme(
primary: Color(Constants.PrimaryColor),
primaryVariant: Color(Constants.PrimaryVariant),
),
textTheme: ButtonTextTheme.normal,
),
),
child: RaisedButton(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(18.0),
side: BorderSide(color: Colors.red),
),
color: Colors.red,
// color: Colors.transparent,
// disabledColor: Colors.grey
textColor: Colors.white,
onPressed: onPressed,
child: Container(
child: Text(title),
),
),
);
}
}
在这里,您可以用 FlatButton 或 outlineButton 替换 RaisedButton,并为所有类型的按钮提供特定的主题。所以你可以重复使用它。
你可以像这样使用它:
SubmitButton(
title: "View Details",
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (_) => GeneratePDF(),
),
);
},
),