美文网首页
Flutter-弹出底部菜单ShowModalBottomShe

Flutter-弹出底部菜单ShowModalBottomShe

作者: 秋分落叶 | 来源:发表于2019-04-08 15:19 被阅读0次

和showBottomSheet相比,主要的区别在于ShowModalBottomSheet在顶部有蒙层,点击会消失,然而showBottomSheet是没有的。

showBottomSheet效果图:

ShowModalBottomSheet 先看一下效果。

下面就看一下Dart语言实现

floatingActionButton: new FloatingActionButton(

        onPressed: () {

          showModalBottomSheet(

              context: context,

              builder: (BuildContext context){

                return new Column(

                  mainAxisSize: MainAxisSize.min,

                  children: <Widget>[

                    new ListTile(

                      leading: new Icon(Icons.photo_camera),

                      title: new Text("Camera"),

                      onTap: () async {

                        imageFile = await ImagePicker.pickImage(source: ImageSource.camera);

                        Navigator.pop(context);

                      },

                    ),

                    new ListTile(

                      leading: new Icon(Icons.photo_library),

                      title: new Text("Gallery"),

                      onTap: () async {

                        imageFile = await ImagePicker.pickImage(source: ImageSource.gallery);

                        Navigator.pop(context);

                      },

                    ),

                  ],

                );

              }

          );

        },

        foregroundColor: Colors.white,

        child: Text('点我'),

      ),

相关文章

网友评论

      本文标题:Flutter-弹出底部菜单ShowModalBottomShe

      本文链接:https://www.haomeiwen.com/subject/vrtpiqtx.html