Hello There Everyone! How's your day going? I hope its brilliant <3
I need a little bit of your help here, I've been using Raw Material Button and Material button lot in my code, But I don't know what is the difference between Raw Material button and Material Button?.
Because they look similar while using them.
Thanks in Advance <3
From docs attached to the classes:
MaterialButtonis utility class for building Material buttons that depend on the ambientButtonThemeandTheme.
and
RawMaterialButtondoes not use the currentThemeorButtonThemeto compute default values for unspecified parameters.
And that's really it - the difference is in the default values. Under the hood MaterialButton is using RawMaterialButton
Widget build(BuildContext context) {
final ThemeData theme = Theme.of(context);
final ButtonThemeData buttonTheme = ButtonTheme.of(context);
return RawMaterialButton(
onPressed: onPressed,
onHighlightChanged: onHighlightChanged,
// so many properties here...
child: child,
materialTapTargetSize: materialTapTargetSize ?? theme.materialTapTargetSize,
);
}
From official Flutter Docs
MaterialButton class
A utility class for building Material buttons that depend on the ambient ButtonTheme and Theme.
The button's size will expand to fit the child widget, if necessary.
MaterialButtons whose onPressed handler is null will be disabled. To have an enabled button, make sure to pass a non-null value for onPressed.
RawMaterialButton class
This class does not use the current Theme or ButtonTheme to compute default values for unspecified parameters.
It's intended to be used for custom Material buttons that optionally incorporate defaults from the themes or from app-specific sources.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With