MaterialStateProperties | Decoding Flutter
Why Stack Overflow recommends it
Stack Overflow users link it when answering errors about passing plain values where a MaterialStateProperty is expected, as the official explanation of how that class works.
Recommended by 2 people across 2 different months, 2021 to 2022.
What it is
A short episode from the official Flutter channel's Decoding Flutter series explaining the MaterialStateProperty class, which lets widget styling values change with Material states such as pressed or hovered. It is presented by Craig Labenz and includes a DartPad demo.
What people said
Recommends Jean JPNM · 2021-12 · Stack Overflow · on “The argument type 'EdgeInsets' can't be assigned to the parameter type 'MaterialStateProperty<EdgeInsetsGeometry?>?'”
Using MaterialStateProperty [LINK] allows you to pass a value that can depend on the state of a material widget (usually a MaterialState [LINK] ). As an example this can prove useful when a button needs to change its color or size when it is being pressed. In your case using MaterialStateProperty.all as bellow should fix it. TextButton( style: ButtonStyle( padding: MaterialStateProperty.all( EdgeInsets.symmetric(vertical: 20.0, horizontal: 60.0), ), ), onPressed: () {}, child: const Text('Text'), ), Its also worth mentioning this similar question [LINK] . Edit: relevant video [this video] from the flutter channel
Recommends Kingshuk Saha · 2022-12 · Stack Overflow · on “Not changing the border color in check box, is there any another way?”
Simply, this should do: Checkbox( fillColor: MaterialStateProperty.all(Colors.blue), shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(5), ), value: false, onChanged: (bool? value) {...}, ), Also Refer to This Video for helpful info [this video] I'd advise you to play with the following parameters overlayColor SplashRadius side It will help you better understand the Checkbox widget. So, there you go. Problem Solved! Happy Coding!
Cites Rashid Wassan · 2021-09 · Stack Overflow · on “The argument type 'MaterialColor' can't be assigned to the parameter type 'MaterialStateProperty<Color>”
Here is a code snippet that shows how I have styled a text button, by using material state properties. You can see how can you add different types of values: TextButton(style: ButtonStyle( padding: MaterialStateProperty.all(const EdgeInsets.all(0)), elevation: MaterialStateProperty.all(8), shape: MaterialStateProperty.all( RoundedRectangleBorder(borderRadius: BorderRadius.circular(50))), backgroundColor: MaterialStateProperty.all(Colors.blue), shadowColor: MaterialStateProperty.all( Theme.of(context).colorScheme.onSurface), ),), I hope this gives you an idea. To know more about MaterialStateProperty, you can go for this official video: MaterialStateProperties | Decoding Flutter [this video]