Play Flutter Quiz. Click here .

How to get the width of the screen?

This Article is posted by seven.srikanth@gmail.com at 29-07-2018 12:20:57



Below code will help you to get the width of the screen in flutter.
double width = MediaQuery.of(context).size.width
Here is an example of how we can get width in widgets,
new Container(
constraints: new BoxConstraints.expand(
width: MediaQuery.of(context).size.width - 20,
),
padding: const EdgeInsets.all(8.0),
color: Colors.teal.shade700,
alignment: Alignment.center,
child: new Text('Hello World',
style: Theme.of(context).textTheme.display1.copyWith(color: Colors.white)),
)
Hope this is useful. 
Thanks,
Srikanth

Tags: How to get the width of the screen in flutter?; Width of mobile Screen;




0 Comments
Login to comment.

Recent Comments

Be the first to Comment. You can ask a Query or Share your toughts or Just say thanks.







© 2018 - Fluttercentral | Email to me - Seven.srikanth@gmail.com

Terms | Privacy