I need to add padding according to the screen size of the user but on adding this code it is showing invalid constant value, can somebody please suggest me the alternative or a better solution.
padding: const EdgeInsets.all(MediaQuery.of(context).size.width/10),
Remove const
and you should be good to go.
padding: EdgeInsets.all(MediaQuery.of(context).size.width/10),
padding: const EdgeInsets.symmetric(horizontal: MediaQuery.of(context).size.width/10), // error
var width = MediaQuery.of(context).size.width;//can be used globally and similarly with height to.
padding: EdgeInsets.symmetric(horizontal:width /10,), //after removing const
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