How to get the width of the screen?

This Article is posted by seven.srikanth at 7/29/2018 12:20:57 PM



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