在Flutter
我想显示简单的ListView
内部showGeneralDialog
对话框。但我收到此错误:
RenderBox was not laid out: RenderFittedBox#d8a97 relayoutBoundary=up1
'package:flutter/src/rendering/box.dart':
Failed assertion: line 1694 pos 12: 'hasSize'
showGeneralDialog(
barrierLabel: "Label",
barrierDismissible: true,
barrierColor: Colors.black.withOpacity(0.5),
transitionDuration: const Duration(milliseconds: 700),
context: context,
pageBuilder: (context, anim1, anim2) {
return Align(
alignment: Alignment.center,
child: BuildPagesPopupMenu(),
);
},
),
class BuildPagesPopupMenu extends StatelessWidget {
final List<MenuItems> _menuItems = [
MenuItems(menuTitle: 'test1 ', icon: Icons.settings),
MenuItems(menuTitle: 'test2 ', icon: Icons.list),
];
@override
Widget build(BuildContext context) {
return Column(
children: <Widget>[
Expanded(
child: ListView.separated(
itemBuilder: (context, index) {
return ListTile(
title: Text(_menuItems[index].menuTitle),
leading: Icon(_menuItems[index].icon),
);
},
separatorBuilder: (context, builder) {
return const Divider();
},
itemCount: _menuItems.length,
),
),
],
);
}
}
class MenuItems {
final String menuTitle;
final IconData icon;
MenuItems({@required this.menuTitle, @required this.icon});
}