Container基础用法
通过color属性生成一个黄色的Container
Container( color: Colors.yellow, );
通过margin属性设置这个Container的外边距
Container( color: Colors.yellow, margin: EdgeInsets.fromLTRB(100, 300, 100, 300), )
通过decoration属性来将这个Container设置成圆形,注意Container的color属性和decoration属性只能存其一,不能同时提供
Container( margin: EdgeInsets.fromLTRB(100, 300, 100, 300), decoration: BoxDecoration( shape: BoxShape.circle, color: Colors.yellow, ), )
为Container加一个绿色的child Container,此时child会充满父widget的空间
Container( color: Colors.yellow, child: Container( color: Colors.green, ), );
为子Container设置宽高并通过alignment属性使其居中:
Container( color: Colors.yellow, alignment: Alignment.center, child: Container( color: Colors.green, width: 200, height: 100, ), );
通过margin来使其居中
Container( color: Colors.yellow, child: Container( color: Colors.green, margin: EdgeInsets.fromLTRB(100, 300, 100, 300), ), );





