Flutter教学

Flutter(26):Material组件之BottomShe

2020-10-01  本文已影响0人  starryxp

Flutter教学目录持续更新中

Github源代码持续更新中

1.BottomSheet介绍

2.showBottomSheet属性

3.showModalBottomSheet属性

4.showBottomSheet

1601463544(1).png
 _myBottomSheet(String s) {
    return Container(
      padding: EdgeInsets.all(10),
      child: Row(
        children: [
          Expanded(
            flex: 1,
            child: Text(
              s,
              style: TextStyle(color: Colors.white, fontSize: 14),
            ),
          ),
          FlatButton(
            onPressed: () {
              Navigator.of(context).pop();
            },
            child: Text(
              '知道了',
              style: TextStyle(color: Colors.white, fontSize: 14),
            ),
          )
        ],
      ),
    );
  }

_showBottomSheet(BuildContext context) {
    showBottomSheet(
      context: context,
      builder: (context) {
        return _myBottomSheet('showBottomSheet');
      },
      backgroundColor: Colors.black54,
      elevation: 10,
      shape: RoundedRectangleBorder(
        borderRadius: BorderRadius.circular(5),
      ),
    );
  }

_scaffoldShowBottomSheet(BuildContext context) {
    Scaffold.of(context).showBottomSheet(
      (context) {
        return _myBottomSheet('scaffoldShowBottomSheet');
      },
      backgroundColor: Colors.black54,
      elevation: 10,
      shape: RoundedRectangleBorder(
        borderRadius: BorderRadius.circular(5),
      ),
    );
  }

5.showModalBottomSheet

1601463569(1).png
_showModalBottomSheet(BuildContext context) {
    showModalBottomSheet(
      context: context,
      builder: (context) {
        return _myBottomSheet('showModalBottomSheet');
      },
      backgroundColor: Colors.black54,
      elevation: 10,
      shape: RoundedRectangleBorder(
        borderRadius: BorderRadius.circular(5),
      ),
      // barrierColor: Colors.amber.shade100,
      isDismissible: false,
      enableDrag: true,
    );
  }

下一节:Material组件之SnackBar

Flutter(27):Material组件之SnackBar

Flutter教学目录持续更新中

Github源代码持续更新中

上一篇下一篇

猜你喜欢

热点阅读