Flutter Layout Container Margin Flutter Layout Container Margin dart dart

Flutter Layout Container Margin


You can use left and right values :)

@overrideWidget build(BuildContext context) {  return Scaffold(    backgroundColor: Colors.white,    body: Container(      margin: const EdgeInsets.only(left: 20.0, right: 20.0),      child: Container(),    ),  );}


You can try: To the margin of any one edge

new Container(    margin: const EdgeInsets.only(left: 20.0, right: 20.0),    child: new Container())

You can try :To the margin of any all edge

new Container(    margin: const EdgeInsets.all(20.0),    child: new Container())

If you need the current system padding or view insets in the context of awidget, consider using [MediaQuery.of] to obtain these values rather thanusing the value from [dart:ui.window], so that you get notified of changes.

new Container(    margin: EdgeInsets.fromWindowPadding(padding, devicePixelRatio),    child: new Container())


Container(  margin: EdgeInsets.all(10) ,  alignment: Alignment.bottomCenter,  decoration: BoxDecoration(    gradient: LinearGradient(      begin: Alignment.topCenter,      end: Alignment.bottomCenter,      colors: <Color>[        Colors.black.withAlpha(0),        Colors.black12,        Colors.black45      ],    ),  ),  child: Text(    "Foreground Text",    style: TextStyle(color: Colors.white, fontSize: 20.0),  ),),