SizedOverflowBox: 子組件在超出SizedOverflowBox指定的寬高時,不會隱藏,依然進行繪制
OverflowBox: 限制子組件的寬高。
import 'package:flutter/material.dart';
class AuthList extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('代碼測試'),
centerTitle: true,
),
body: Container(
height: 100.0,
width: 100.0,
color: Colors.black26,
child: OverflowBox(
maxWidth: 80.0,
minWidth: 50.0,
minHeight: 50.0,
maxHeight: 80.0,
child: Container(
width: 100.0,
height: 200.0,
color: Colors.blue,
),
),
)
);
}
}
如下子組件藍色的Container的
最大高度不會超過80,最小高度不會小於50.
最大寬度不會超過80,最小高度不會小於50.