PreferredSize
此控件不对其子控件施加任何约束,并且不以任何方式影响孩子的布局。
常用来自定义AppBar和AppBar.bottom(PreferredSize子控件为AppBar或者AppBar.bottom)
Scaffold(
appBar: PreferredSize(
preferredSize: Size.fromHeight(200),
child: Container(
color: Colors.blue,
),
),
body: Test1(),
)
AppBar.bottom通常是TabBar等,通过PreferredSize可设置为任意组件:
Scaffold(
appBar: AppBar(
bottom: PreferredSize(
preferredSize: Size.fromHeight(48),
child: Container(
height: 48,
color: Colors.red,
),
),
),
body: Test1(),
)