utk*_*rsh 6 flutter flutter-layout flutter-showmodalbottomsheet
在下面的示例中,我在按下“凸起”按钮时打开了一个模态底部工作表在打开的工作表中,我有另一个图标可以打开另一个工作表,但我想在打开第二个底部后关闭第一个工作表床单。我怎样才能实现这个目标?
import 'package:flutter/material.dart';
class SecondScreen extends StatefulWidget {
@override
_SecondScreenState createState() => _SecondScreenState();
}
class _SecondScreenState extends State<SecondScreen> {
@override
Widget build(BuildContext context) {
return Center(
child: Container(
child:RaisedButton(child: Text('Click'), onPressed: () => _openSheet()),
),
);
}
_openSheet() {
showModalBottomSheet(
context: context,
builder: (BuildContext context)
{
return Column(
children: <Widget>[
Container(
height: MediaQuery.of(context).size.height / 2,
width: MediaQuery.of(context).size.width,
child: IconButton(
icon: Icon(Icons.info),
iconSize: 50.0,
onPressed: () => _openSecondSheet(),
),
),
],
);
});
}
_openSecondSheet() {
showModalBottomSheet(
context: context,
builder: (BuildContext context) {
return Container(
height: MediaQuery.of(context).size.height / 3,
width: MediaQuery.of(context).size.width,
);
});
}
}
Run Code Online (Sandbox Code Playgroud)
当打开第二只羊时,先打开pop第一只羊。
onPressed: () {
Navigator.pop(context);
_openSecondSheet()
},
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3809 次 |
| 最近记录: |