【问题标题】:I'm trying to create a button below a listView and all of that within a modalBottomSheet, but I'm failing at that我正在尝试在 listView 下方创建一个按钮,并在 modalBottomSheet 中创建所有这些按钮,但我失败了
【发布时间】:2021-04-04 06:57:40
【问题描述】:

这是我到目前为止的代码,错误是当我尝试将它放在列中时,但没有列,在 listView.separed 中的右侧不允许我添加按钮。

showModalBottomSheet(
    context: context,
    builder: (context) {
      return BottomSheet(
          backgroundColor: Colors.black45,
          onClosing: () {},
          builder: (context) {
            return Column(
              children: <Widget>[
                ListView.separated(
                    separatorBuilder: (BuildContext context, int index) =>
                    const Divider(),
                    padding: EdgeInsets.fromLTRB(
                        10, 10, 10, MediaQuery.of(context).viewInsets.bottom),
                    itemCount: _playersList.length,
                    itemBuilder: (context, index) {
                      _controlers.add(TextEditingController());
                      return TextField(
                        style: TextStyle(color: Colors.white),
                        decoration: InputDecoration(
                            labelText: _playersList[index].name,
                            labelStyle: TextStyle(color: Colors.white)),
                        controller: _controlers[index],
                        keyboardType: TextInputType.number,
                      );
                    }),
                RaisedButton(onPressed: null, child: Icon(Icons.save))
              ],
            );
          });
    });

【问题讨论】:

  • 你得到什么错误?

标签: flutter flutter-layout


【解决方案1】:

在 ListView.separated 中将 shrinkWrap 设置为 true。

【讨论】:

  • 我是 Flutter 的初学者,没想到这么简单。非常感谢!!
猜你喜欢
  • 2017-09-17
  • 2016-02-20
  • 1970-01-01
  • 2021-07-24
  • 2014-09-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多