简体   繁体   中英

How to control width of modalBottomSheet in flutter?

我想让我的底部工作表不采用无限宽如何使我尝试嵌套容器和宽度为 100 的嵌套容器并且它也占用整个宽度?

You can check the below code.

   RaisedButton(
        child: Text("abc"),
        onPressed: () {
          showModalBottomSheet(
              context: context,
              backgroundColor: Colors.transparent,
              builder: (BuildContext bc) {
                return Container(
                  width: MediaQuery.of(context).size.width,
                  color: Colors.transparent,
                  child: Padding(
                    padding: const EdgeInsets.fromLTRB(100, 0, 100, 0),
                    child: Container(
                      color: Colors.white,
                      width: MediaQuery.of(context).size.width - 200,
                      child: new Wrap(
                        children: <Widget>[
                          new ListTile(
                              leading: new Icon(Icons.music_note),
                              title: new Text('Music'),
                              onTap: () => {}),
                          new ListTile(
                            leading: new Icon(Icons.videocam),
                            title: new Text('Video'),
                            onTap: () => {},
                          ),
                        ],
                      ),
                    ),
                  ),
                );
              });
        })

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM