底部弹出内容,点击其他区域,弹出内容弹回
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);
});
}
}
结果: