防采集标记:亢少军老师的课程和资料
import 'package:flutter/material.dart';
class LayoutDemo extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(
title: new Text('OverflowBox溢出父容器显示示例'),
),
body: Container(
color: Colors.green,
width: 200.0,
height: 200.0,
padding: const EdgeInsets.all(5.0),
child: OverflowBox(
alignment: Alignment.topLeft,
maxWidth: 300.0,
maxHeight: 500.0,
child: Container(
color: Colors.blueGrey,
width: 400.0,
height: 400.0,
),
),
));
}
}
void main() {
runApp(
new MaterialApp(
title: 'OverflowBox溢出父容器显示示例',
home: new LayoutDemo(),
),
);
}
- Flutter技术入门与实战: http://product.dangdang.com/26485813.html
- Flutter交流学习群:894109159
- Flutter开源项目请关注: https://github.com/kangshaojun
- Flutter视频教程:https://edu.youkuaiyun.com/lecturer/2436
@作者: 亢少军

本文详细介绍了Flutter中OverflowBox组件的使用方法,展示了如何让子组件溢出其父容器并控制最大宽度和高度,适用于需要灵活布局的场景。
3275

被折叠的 条评论
为什么被折叠?



