class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'FittedBox',
home: Scaffold(
appBar: AppBar(title: Text('FittedBox')),
body: Center(
child: Column(
children: [
Container(
width: 100,
height: 100,
child: FittedBox(
//内容填充模式,有点类似于背景图片的填充
fit: BoxFit.fill,
alignment: Alignment.center,
child: Container(
color: Colors.green,
child: Text(
'fill填充模式',
style: TextStyle(color: Colors.white),
),
),
),
),
],
),
),
),
);
}
} Flutter笔记7:FittedBox内容填充
FittedBox内容填充模式,就是对内容进行裁切、压缩等,以适应与子容器的大小,有点类似于背景图片的填充
