showNavigationSheet static method

dynamic showNavigationSheet(
  1. BuildContext context,
  2. double longitude,
  3. double latitude
)

Implementation

static showNavigationSheet(BuildContext context, double longitude, double latitude) {
  List<Map<String, dynamic>> list = [
    {'title': '高德地图', 'func': () => _gotoAMap(longitude, latitude)},
    {'title': '百度地图', 'func': () => _gotoBaiduMap(longitude, latitude)},
    {'title': '腾讯地图', 'func': () => _gotoTencentMap(longitude, latitude)},
  ];
  if (Platform.isIOS) {
    list.add({'title': '苹果地图', 'func': () => _gotoAppleMap(longitude, latitude)});
  }
  showCupertinoModalPopup(
    context: context,
    builder: (BuildContext context) {
      return CupertinoActionSheet(
        cancelButton: CupertinoActionSheetAction(
          onPressed: () => Navigator.pop(context),
          child: const Text('取消'),
        ),
        actions: list
            .map((e) => CupertinoActionSheetAction(
                  onPressed: () {
                    e['func']();
                    Navigator.of(context).pop();
                  },
                  child: Text(e['title']),
                ))
            .toList(),
      );
    },
  );
}