01 | class MyApp extends StatelessWidget { |
02 | @override |
03 | Widget build(BuildContext context) { |
04 | return MaterialApp( |
05 | title: 'FittedBox' , |
06 | home: Scaffold( |
07 | appBar: AppBar(title: Text( 'FittedBox' )), |
08 | body: Center( |
09 | child: Column( |
10 | children: [ |
11 | Container( |
12 | width: 100, |
13 | height: 100, |
14 | child: FittedBox( |
15 | //内容填充模式,有点类似于背景图片的填充 |
16 | fit: BoxFit.fill, |
17 | alignment: Alignment.center, |
18 | child: Container( |
19 | color: Colors.green, |
20 | child: Text( |
21 | 'fill填充模式' , |
22 | style: TextStyle(color: Colors.white), |
23 | ), |
24 | ), |
25 | ), |
26 | ), |
27 | ], |
28 | ), |
29 | ), |
30 | ), |
31 | ); |
32 | } |
33 | } |
部分素材资源来源网站,本站提供免费下载,如有侵权请联系站长马上删除!