我希望我的 ListView 不与其他元素重叠。
这是我的代码,希望你们能帮助我解决我的问题。谢谢你。
return AlertDialog(
surfaceTintColor: colors.background,
contentPadding:
const EdgeInsets.symmetric(horizontal: 16, vertical: 24),
insetPadding: const EdgeInsets.symmetric(horizontal: 16, vertical: 16),
content: SizedBox(
height: screenSize.height - 125,
width: screenSize.width,
child: Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Center(
child: Text(
'Saved Addresses',
style: Theme.of(context).textTheme.labelLarge?.copyWith(
fontSize: 20,
fontWeight: FontWeight.bold,
),
),
),
const SavedLocationsListWidget(),
Align(
alignment: Alignment.bottomCenter,
child: SizedBox(
height: 44,
child: UtolButtonIcon(
colors: colors.secondary,
label: Text(
'Cancel',
style: Theme.of(context).textTheme.labelLarge?.copyWith(
color: Colors.white,
fontWeight: FontWeight.bold,
),
),
icon: const Icon(
Icons.close_fullscreen_outlined,
color: Colors.white,
size: 20,
),
onPressed: () {
Navigator.of(context).pop();
},
),
),
),
], // Button
我尝试使用 SizedBox 但列表消失了。 将它们包裹在 Padding 中也不起作用
return AlertDialog(
contentPadding:
const EdgeInsets.symmetric(horizontal: 16, vertical: 24),
insetPadding:
const EdgeInsets.symmetric(horizontal: 16, vertical: 16),
content: SizedBox(
height: screenSize.height - 125,
width: screenSize.width,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Center(
child: Text(
'Saved Addresses',
style: Theme.of(c).textTheme.labelLarge?.copyWith(
fontSize: 20,
fontWeight: FontWeight.bold,
),
),
),
const SizedBox(height: 10),
Expanded(
child: ListView.separated(
separatorBuilder: (c, i) =>
const SizedBox(height: 10),
itemCount: 25,
itemBuilder: (c, i) {
return DecoratedBox(
decoration: BoxDecoration(
border: Border.all(
color: Colors.indigo, width: 1),
borderRadius: BorderRadius.circular(15),
),
child: ListTile(
title: Text('Item ${i + 1}'),
));
}),
),
Align(
alignment: Alignment.bottomCenter,
child: SizedBox(
height: 44,
child: TextButton.icon(
label: Text(
'Cancel',
style: TextStyle(
color: Colors.indigo,
fontWeight: FontWeight.bold,
),
),
icon: const Icon(
Icons.close_fullscreen_outlined,
color: Colors.white,
size: 20,
),
style: TextButton.styleFrom(
backgroundColor: Colors.red,
),
onPressed: () {
Navigator.of(c).pop();
},
),
),
)
])));