I am trying to set minWidth in ButtonTheme. I am getting following error:
Error: Getter not found: 'context'.
compiler message: minWidth: MediaQuery.of(context).size.width-40,
For reference I am sharing code here:
final resetButton = ButtonTheme(
minWidth: MediaQuery.of(context).size.width-40,
height: 50.0,
child: new RaisedButton(
color: blueColor,
onPressed: (){
// Navigator.of(context).pushNamed(Home.tag);
},
child: Text('Log In',
style: styleLoginButton,
),
shape: new RoundedRectangleBorder(borderRadius: new BorderRadius.circular(30.0))
),
);
You can't use MediaQuery.of(context)
when there is no context. Either pass context
when you call this code from build(BuildContext context) { ... }
or move the code to build() { ... }