flutter container width 100 percent code example

Example 1: flutter container width of parent

width: double.infinity,
  height: double.infinity

Example 2: set container height flutter 25% of screen

MediaQuery.of(context).size.height * 0.25

Example 3: flutter get parent width

var container = new Container(
  // Toggling width from 100 to 300 will change what is rendered
  // in the child container
  width: 100.0,
  // width: 300.0
  child: new LayoutBuilder(
    builder: (BuildContext context, BoxConstraints constraints) {
      if(constraints.maxWidth > 200.0) {
        return new Text('BIG');
      } else {
        return new Text('SMALL');
      }
    }
  ),
);

Example 4: flutter image size percentage

Expanded(child: Image.asset("assets/mypic.jpg")),

Tags:

Dart Example