Reputation: 1751
My app will be used for different devices and different screen sizes and a well coded app should shown same at different screen sizes. Flutter has MediaQuery.of(context).size property. I wanna give a padding value to Padding widget like "padding: EdgeInsets.only(top: _height/3)" but it is not acceptable. Just static values has accept for padding. How to write a dynamic value to padding?
I tried to determine that "var _paddingTop = _height/3" at initState and still it isn't acceptable.
Padding(
padding: EdgeInsets.only(top: _height/4),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
// some widgets
],
),
),
Upvotes: 5
Views: 5030
Reputation: 15741
just remove the const
Padding(
padding: EdgeInsets.only(top: _height/4),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
// some widgets
],
),
),
Upvotes: 7