请给一个Flutter中使用showCupertinoModalPopup的示例
时间: 2023-02-02 14:39:50 浏览: 128
下面是一个使用 showCupertinoModalPopup 的 Flutter 示例:
```
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: Center(
child: RaisedButton(
onPressed: () {
showCupertinoModalPopup(
context: context,
builder: (BuildContext context) {
return CupertinoActionSheet(
actions: <Widget>[
CupertinoActionSheetAction(
child: Text('选项 1'),
onPressed: () {},
),
CupertinoActionSheetAction(
child: Text('选项 2'),
onPressed: () {},
),
CupertinoActionSheetAction(
child: Text('选项 3'),
onPressed: () {},
),
],
cancelButton: CupertinoActionSheetAction(
child: Text('取消'),
onPressed: () {
Navigator.pop(context);
},
),
);
},
);
},
child: Text('打开弹窗'),
),
),
),
);
}
}
```
阅读全文