底部弹出内容,点击其他区域,弹出内容弹回
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('BottomNavigationBar Sample'),
),
body: Center(
child: new ListView(
children: <Widget>[
new FlatButton(
onPressed: _showMyModelBottomSheet,
child: new Text('date picker'),
),
],
),
),
);
}
void _showMyModelBottomSheet() {
showModalBottomSheet(
context: context,
builder: (BuildContext context) {
// 此处可以自定义任何内容
return new Container(
height: 300.0,
child: new Text('我是modelbottomSheet'),
);
}
).then((val) {
print(val);
});
}
}
结果:
![2988687-e4a4dad35e16d7ef.png](https://upload-images.jianshu.io/upload_images/2988687-e4a4dad35e16d7ef.png)
Simulator Screen Shot - iPhone XS - 2019-01-21 at 12.12.34.png