最近有个需求,需要自定义一个分享view,在多个地方都会用到。考虑到易用性,我封装成了类方法,一行代码就可以调用了,很方便,实现也很简单,使用系统提供的showModalBottomSheet方法即可,该方法会自动有个阴影背景,点击阴影背景,会回收弹出的view 效果: 封装的代码 import 'package:flutter/material.dart'; class CustomShareView extends StatelessWidget { final List buttonTitles = ["微信好友","朋友圈","新浪微博"]; final List buttonImages = ["shareview_contact.png", "shareview_friendsshare.png", "shareview_weibo.png"]; static showShareView(BuildContext context) { showModalBottomSheet(context: context, backgroundColor: Colors.white.withAlpha(0), elevation: 2, builder: (BuildContext context){ return ClipRRect(