我试图呈现一个列(在CupertinoPageScaffold内部),其中该列在展开的列表视图之前和之后(在子级中)具有小部件。呈现在列表视图之后的小部件,但不呈现在列表视图之前的小部件。 Link to image with rendered screen
class TestWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Column(
children: <Widget>[
Container(
constraints: BoxConstraints(
minHeight: 50.0,
),
child: Center(
child: Text(
'Top label',
style: TextStyle(
fontSize: 22.0,
fontWeight: FontWeight.bold,
color: Colors.teal),
),
),
),
Expanded(
child: ListView.separated(
itemCount: 20,
separatorBuilder: (context, index) {
return Divider();
},
itemBuilder: (context, index) {
return Material(
child: ListTile(
leading: CircleAvatar(),
title: Text('Test title'),
),
);
},
),
),
Container(
constraints: BoxConstraints(
minHeight: 50.0,
),
child: Center(
child: Text(
'Bottom label',
style: TextStyle(
fontSize: 22.0,
fontWeight: FontWeight.bold,
color: Colors.teal),
),
),
),
],
);
}
}
答案 0 :(得分:1)
只需在TestWidget
内添加SafeArea
即可。
SafeArea(
child: TestWidget()
);