Flutter Container Widget Examples – Full Screen, Border and Radius

Container is a widget that combines common painting, positioning, and sizing widgets. Flutter Container widget is used frequently in a Flutter app’s screen.

Container(
          padding: const EdgeInsets.all(16.0),
          color: Colors.blue,
          width: 100.0,
          height: 100.0,
          child: Text('100.0'),
        )

Make container fill the whole screen

Container(
          padding: const EdgeInsets.all(16.0),
          color: Colors.blue,
          width: double.infinity,
          height: double.infinity,
          child: Text('infinity'),
        )
Container(
          padding: const EdgeInsets.all(16.0),
          color: Colors.blue,
          width: MediaQuery.of(context).size.width,
          height: MediaQuery.of(context).size.height,
          child: Text('media size'),
        )

Container with border and radius

Container(
          padding: const EdgeInsets.all(8.0),
          width: 200.0,
          height: 200.0,
          decoration: BoxDecoration(
              border: Border.all(color: Colors.blueAccent),
              borderRadius: BorderRadius.all(Radius.circular(6.0)),
          ),
          child: Text("Border"),
        )

Leave a Comment

Your email address will not be published. Required fields are marked *

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close