Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Dart 如何减少ListView.builder中升起的按钮的宽度?_Dart_Flutter - Fatal编程技术网

Dart 如何减少ListView.builder中升起的按钮的宽度?

Dart 如何减少ListView.builder中升起的按钮的宽度?,dart,flutter,Dart,Flutter,我似乎不知道如何减少ListView.builder中RaisedButton的宽度 ListView.builder( itemCount: streetList.length, itemBuilder: (context, index) { bool first = 0 == (index); bool last = streetList.length - 1 == (index);

我似乎不知道如何减少
ListView.builder中
RaisedButton
的宽度

ListView.builder(
          itemCount: streetList.length,
          itemBuilder: (context, index) {
            bool first = 0 == (index);
            bool last = streetList.length - 1 == (index);
            EdgeInsets itemEdges = EdgeInsets.only(bottom: 20);

            if (first) {
              itemEdges = EdgeInsets.only(top: 50, bottom: 20);
            } else if (last) {
              itemEdges = EdgeInsets.only(bottom: 50);
            }

            return Container(
              margin: EdgeInsets.symmetric(horizontal: 30),
              padding: itemEdges,
              child: SizedBox(
                // height: 50,
                child: RaisedButton(
                  child: Text(streetList[index]),
                  onPressed: () {
                    Navigator.push(
                      context,
                      MaterialPageRoute(
                        builder: (context) => StreetNumberList(
                            widget.peopleList, (streetList[index])),
                      ),
                    );
                  },
                ),
              ),
            );
          }),
我明白了:

我试图减小
raised按钮的宽度,但它看起来像
ListView。生成器
项设置为始终使用最大宽度。我怎么能推翻这一点


谢谢

如果您想要
RaisedButton
的默认大小,只需将
Align
小部件添加为父项即可

    return Container(
                  margin: EdgeInsets.symmetric(horizontal: 30),
                  padding: itemEdges,
                  child: Align(
                      child: RaisedButton(
                        child: Text("index: $index"),
                        onPressed: () {},

                    ),
                  ),
                );
如果要更改大小,请使用
SizedBox
内部
Align

    return Container(
                  margin: EdgeInsets.symmetric(horizontal: 30),
                  padding: itemEdges,
                  child: Align(
                    child: SizedBox(
                      width: 250,
                      child: RaisedButton(
                        child: Text("index: $index"),
                        onPressed: () {},
                      ),
                    ),
                  ),
                );

正是我要找的!