美文网首页
flutter showModalBottomSheet 底部弹

flutter showModalBottomSheet 底部弹

作者: 银弹星空 | 来源:发表于2021-04-29 17:42 被阅读0次

    构造方法

    Future<T> showModalBottomSheet<T>({
      @required BuildContext context,
      @required WidgetBuilder builder,
      Color backgroundColor,
      double elevation,
      ShapeBorder shape, //弹窗shape可以设置圆角
      Clip clipBehavior,
      Color barrierColor,
      bool isScrollControlled = false,
      bool useRootNavigator = false,
      bool isDismissible = true,//能否点击消失
      bool enableDrag = true,//能否拖拽消失
    })
    

    使用

      _showPopWindow() {
        showModalBottomSheet<String>(
            context: context,
            isDismissible: false,//设置点击弹窗外边是否关闭页面
            shape: RoundedRectangleBorder(
              borderRadius: BorderRadius.only(topLeft: Radius.circular(20),topRight: Radius.circular(20)),
            ),
            builder: (BuildContext context) {
              return Container(
                padding: EdgeInsets.symmetric(vertical: ScreenUtil().setHeight(30)),
                child: Column(
                  mainAxisSize: MainAxisSize.min,
                  children: <Widget>[
                    ListTile(
                      leading: new Icon(Icons.photo_camera),
                      title: new Text("Camera"),
                      onTap: () async {
                        Navigator.pop(context, 'camera');
                      },
                    ),
                    ListTile(
                      leading: new Icon(Icons.photo_library),
                      title: new Text("Gallery"),
                      onTap: () async {
                        Navigator.pop(context, 'Gallery');
                      },
                    ),
                  ],
                ),
              );
            }).then((value) => print('showModalBottomSheet $value'));
      }
    

    相关文章

      网友评论

          本文标题:flutter showModalBottomSheet 底部弹

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