Ran*_*erk 10 dart flutter flutter-layout
这是完整的代码:
class Application extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new MaterialApp(
home: new Scaffold(
body: new Container(
color: Color(0xff258DED),
height: 400.0,
alignment: Alignment.center,
child: new Container(
height: 200.0,
width: 200.0,
decoration: new BoxDecoration(
image: DecorationImage(
image: new AssetImage('assets/logo.png'),
fit: BoxFit.fill
),
shape: BoxShape.circle
),
),
child: new Container(
child: new Text('Welcome to Prime Message',
textAlign: TextAlign.center,
style: TextStyle(
fontFamily: 'Aleo',
fontStyle: FontStyle.normal,
fontWeight: FontWeight.bold,
fontSize: 25.0,
color: Colors.white
),
),
),
),
),
);
}
}
Run Code Online (Sandbox Code Playgroud)
我尝试Container在顶部添加一个,然后在其中添加两个孩子。第一个孩子工作正常,但第二个孩子给了我错误,比如“已经指定了命名参数'child'的参数”。
小智 15
如果您尝试将多个孩子放入一个容器中,您希望将其视为Row()或Column()类为线性的。Stack()如果您想让浮动孩子彼此重叠,则使用。
例如:
class Application extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new MaterialApp(
home: new Scaffold(
body: new Container(
color: Color(0xff258DED),
height: 400.0,
alignment: Alignment.center,
child: new Column(
children: [
new Container(
height: 200.0,
width: 200.0,
decoration: new BoxDecoration(
image: DecorationImage(
image: new AssetImage('assets/logo.png'),
fit: BoxFit.fill
),
shape: BoxShape.circle
),
),
new Container(
child: new Text('Welcome to Prime Message',
textAlign: TextAlign.center,
style: TextStyle(
fontFamily: 'Aleo',
fontStyle: FontStyle.normal,
fontWeight: FontWeight.bold,
fontSize: 25.0,
color: Colors.white
),
),
),
],
),
),
),
);
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
29126 次 |
| 最近记录: |