【发布时间】:2020-11-15 09:47:39
【问题描述】:
我正在尝试在颤振中显示一个包含 Switch 的 showCupertinoModalPopup,它可以正确显示,但不会更新 Switch。为什么 Switch 在 CupertinoActionSheet 更新后不保持新状态?
https://github.com/flutter/flutter/issues/62264
Future<int> countAsReturnVisit(CalendarEvent event) async {
bool remember = false;
var res = await showCupertinoModalPopup(
context: context,
builder: (BuildContext cnt) {
return Material(
color: Colors.transparent,
child: CupertinoActionSheet(
message: Wrap(
children: <Widget>[
Text(
'Do you want to count \'Completed\' events as part of Return Visits?'
.i18n),
Container(
height: 50,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Text('Remember this selection'.i18n),
Switch(
value: remember,
onChanged: (value) {
setState(() {
remember = value;
});
},
activeTrackColor: Colors.lightBlue[200],
activeColor: Colors.blue,
),
],
),
),
],
),
actions: <Widget>[
CupertinoActionSheetAction(
child: Text('No'.i18n),
onPressed: () {
Navigator.pop(context, 0);
},
),
],
cancelButton: CupertinoActionSheetAction(
isDefaultAction: true,
child: Text('Yes'.i18n),
onPressed: () {
Navigator.pop(context, 1);
},
),
),
);
},
) as int;
if (res != null && res == 1) {
setCalendarAlwaysCountAsRrtuVist();
}
return res;
}
【问题讨论】:
标签: flutter