Flutter minWidth和maxWidth 限制容器
2023-09-14 08:58:44 时间
对其子级施加其他(minWidth,maxWidth,minHeight,maxHeight)约束
class _HomePageState extends State<HomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child: ConstrainedBox(
constraints: BoxConstraints(
minHeight: 50,
minWidth: 50,
// minWidth: double.infinity, // //宽度尽可能大
),
child: _buildChild(
width: 50 + 10.0,
height: 40,
),
),
),
),
);
}
Container _buildChild({
double width,
double height,
}) {
return Container(
height: height,
width: width,
color: Colors.red,
);
}
}
相关文章
- Flutter NotificationListener 监听列表的滚动
- Flutter: AnimatedList 一个滚动容器,可在插入或移除项目时为其设置动画
- Flutter:升级用到的第三方库(Flutter 3.7.0)
- [Flutter] lib/main.dart:1: Warning: Interpreting this as package URI, 'package:flutter_app/main.dart'.
- 都2023年了,Flutter还有必要学吗?
- Flutter进阶第4篇: 实现简单的新闻系统渲染新闻详情数据以及用flutter_html解析html
- Flutter — 实现验证码倒计时功能
- Flutter报错 使用Column等容器包裹ListView报错的问题
- flutter 实现消息提醒弹窗
- flutter 键盘弹起时有溢出
- flutter 点击效果
- Flutter Unable to ‘pub upgrade‘ flutter tool
- Flutter 开发环境搭建Unable to ‘pub upgrade‘ flutter tool. Retrying in five seconds...
- Flutter之CupertinoSwitch和Switch开关组件的简单使用
- Flutter实战之Hello Flutter
- Flutter 耗时监控 | 路由名为空原因分析
- Flutter 官方自带日期组件 和第三方 日期组件、轮播图 flutter_swiper