🚨
Flutter で UIAlertController ActionSheet を実装する
iOS の UIAlertController で UIAlertController.Style.actionSheet を Flutter で実装する機会があったので知見として残します。
こんなやつ
実装
CupertinoActionSheetAction の onPressed でも Navigator.of(context).pop() してあげたほうがいいかもしれません。
UIAlertController と異なり自動でpopしてくれないみたいでした
showCupertinoModalPopup(
context: context,
builder: (BuildContext context) {
return CupertinoActionSheet(
title: Text('Please enter a title'),
actions: [
CupertinoActionSheetAction(
child: Text('hoge'),
onPressed: () => {},
),
CupertinoActionSheetAction(
child: Text('fuga'),
onPressed: () => {},
),
],
cancelButton: CupertinoButton(
child: Text('cancel'),
onPressed: () => Navigator.of(context).pop(),
),
);
},
);
Discussion