1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
//函数
_showCupertinoActionSheet() async{
    var result = await showCupertinoModalPopup(
        context: context,
        builder: (context) {
          return CupertinoActionSheet(

            title: Text('标题'),
            message: Text('内容'),
            actions: <Widget>[
              CupertinoActionSheetAction(
                child: Text(
                    '标题一',
                  style: TextStyle(
                    color: Color(0xFF00C599)
                  ),
                ),
                onPressed: () {
                  Navigator.of(context).pop('delete');
                },
                isDefaultAction: true,
              ),
              
              CupertinoActionSheetAction(
                child: Text('标题二'),
                onPressed: () {
                  Navigator.of(context).pop('not delete');
                },
                isDestructiveAction: true,
              ),
            ],
            cancelButton: CupertinoActionSheetAction(
              child: Text(
                  '取消',
                style: TextStyle(
                  color: Colors.white
                ),
              ),
              onPressed: () {
                Navigator.of(context).pop('cancel');
              },
            ),
          );
        });
    print('$result');
  }

总结:在showCupertinoModalPopup方法里返回CupertinoActionSheet,里面的元素由CupertinoActionSheetAction组成,有default和destructive类型可选,用法和UI和苹果大致一样

image