BottomSheet是一个从屏幕底部滑起的列表(以显示更多的内容)。你可以调用showBottomSheet()或showModalBottomSheet弹出

import 'package:flutter/material.dart';
import 'dart:async'; class BottomSheetDemo extends StatefulWidget {
@override
_BottomSheetDemoState createState() => _BottomSheetDemoState();
} class _BottomSheetDemoState extends State<BottomSheetDemo> {
final _bottomSheetScaffoldKey = GlobalKey<ScaffoldState>(); _openBottomSheet() {
_bottomSheetScaffoldKey
.currentState
.showBottomSheet((BuildContext context) {
return BottomAppBar(
child: Container(
height: 90.0,
width: double.infinity,
padding: EdgeInsets.all(16.0),
child: Row(
children: <Widget>[
Icon(Icons.pause_circle_outline),
SizedBox(width: 16.0,),
Text('01:30 / 03:30'),
Expanded(
child: Text('从头再来-刘欢', textAlign: TextAlign.right,),
),
],
),
),
);
});
} Future _openModalBottomSheet() async {
final option = await showModalBottomSheet(
context: context,
builder: (BuildContext context) {
return Container(
height: 200.0,
child: Column(
children: <Widget>[
ListTile(
title: Text('拍照',textAlign: TextAlign.center),
onTap: () {
Navigator.pop(context, '拍照');
},
),
ListTile(
title: Text('从相册选择',textAlign: TextAlign.center),
onTap: () {
Navigator.pop(context, '从相册选择');
},
),
ListTile(
title: Text('取消',textAlign: TextAlign.center),
onTap: () {
Navigator.pop(context, '取消');
},
),
],
),
);
}
); print(option);
} @override
Widget build(BuildContext context) {
return Scaffold(
key: _bottomSheetScaffoldKey,
appBar: AppBar(
title: Text('BottomSheetDemo'),
elevation: 0.0,
),
body: Container(
padding: EdgeInsets.all(16.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
FlatButton(
child: Text('Open BottomSheet'),
onPressed: _openBottomSheet,
),
FlatButton(
child: Text('Modal BottomSheet'),
onPressed: _openModalBottomSheet,
),
]
),
],
),
),
);
}
}

效果:

文档:https://api.flutter.dev/flutter/material/BottomSheet-class.html

最新文章

  1. Eclipse 使用技巧
  2. vue DatePicker vue2.0的日期插件
  3. C++Builder XE8_upd1破解安装成功纪要
  4. (转)Android: NDK编程入门笔记
  5. 第二百九十三天 how can I 坚持
  6. AspNet MVC : 操作/控制器过滤器(action filter)
  7. 免费 Bootstrap 管理后台模块下载
  8. 使用CAShapeLayer和UIBezierPath画一个自定义半圆弧button
  9. NodeJS基本使用简介
  10. 什么是 lnmp 实现原理。
  11. mybatis常见问题和错误
  12. Echo团队Alpha冲刺随笔 - 第三天
  13. 《jquery实战》javascript 必知必会(2)
  14. VC CListCtrl 第一列列宽自适应
  15. apache Header set Cache-Control
  16. xStream完美转换XML、JSON(转)
  17. 微信小程序参考资料及网址
  18. qt程序异常结束crashed
  19. copyin函数
  20. 2017 JUST Programming Contest 3.0 E. The Architect Omar

热门文章

  1. Django之路——3 Django的路由层
  2. test20190504 行走
  3. 结构型模式(三) 装饰模式(Decorator)
  4. java集合Map
  5. SpringBoot基础及FreeMarker模板
  6. (尚004)Vue计算属性之基本使用和监视
  7. HTML5类操作
  8. 洛谷 P2032 扫描 题解
  9. 洛谷 P1638 逛画展 题解
  10. pcl-qt使用QVTKWidget 与PCLVisualizer 显示雷达点云