我爱模板网 > 建站教程 > APP开发,混合APP >  Flutter笔记7:FittedBox内容填充正文

Flutter笔记7:FittedBox内容填充

FittedBox内容填充模式,就是对内容进行裁切、压缩等,以适应与子容器的大小,有点类似于背景图片的填充
01class 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}


部分素材资源来源网站,本站提供免费下载,如有侵权请联系站长马上删除!
上一篇:Flutter笔记6:DecoratedBox装饰盒子 下一篇:Flutter笔记8:RotatedBox旋转Widget
发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
选择头像:
最新评论

猜你喜欢