我是新手,一直在尝试在ListView.builder
/ BottomSheet
内创建SingleChildScrollView
。外面有人知道我在做什么错吗?
////════════渲染库捕获异常 ══════════════════════════════════════════════════ following以下 在performLayout()期间引发了断言: 'package:flutter / src / rendering / object.dart':断言失败:行 1651 pos 12:'!_debugDoingThisLayout':不正确。
代码
class AddMenuScreen extends StatefulWidget {
@override
_AddMenuScreenState createState() => _AddMenuScreenState();
}
class _AddMenuScreenState extends State<AddMenuScreen> {
List<MenuWidget> listMenu = [];
addMenu() {
listMenu.add(new MenuWidget());
setState(() {});
}
@override
Widget build(BuildContext context) {
return Container(
color: Color(0xff575757),
child: Container(
padding: EdgeInsets.all(20.0),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(30.0),
topRight: Radius.circular(30.0),
),
),
child: Column(
children: <Widget>[
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 8.0),
child: Text(
'Add items',
style: TextStyle(
fontSize: 30.0,
color: Colors.blueAccent,
fontWeight: FontWeight.bold),
),
),
Expanded(
child: ListView.builder(
itemCount: listMenu.length,
shrinkWrap: true,
itemBuilder: (_, index) => listMenu[index]),
),
],
),
),
);
}
}
class MenuWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
child: TextField(
decoration: InputDecoration(hintText: 'Altenativ'),
autofocus: true,
// textAlign: TextAlign.center,
),
);
}
}