pikapika/lib/basic/config/WillPopNotice.dart

42 lines
1.0 KiB
Dart
Raw Normal View History

2022-08-11 03:21:55 +00:00
import 'package:flutter/material.dart';
import '../Common.dart';
import '../Method.dart';
const _propertyName = "willPopNotice";
late bool _willPopNotice;
Future initWillPopNotice() async {
_willPopNotice = (await method.loadProperty(_propertyName, "false")) == "true";
}
bool willPopNotice() {
return _willPopNotice;
}
Future<void> _chooseWillPopNotice(BuildContext context) async {
String? result =
await chooseListDialog<String>(context, "退出APP的提示", ["", ""]);
if (result != null) {
var target = result == "";
await method.saveProperty(_propertyName, "$target");
_willPopNotice = target;
}
}
Widget willPopNoticeSetting() {
return StatefulBuilder(
builder: (BuildContext context, void Function(void Function()) setState) {
return ListTile(
title: const Text("退出APP的提示"),
subtitle: Text(_willPopNotice ? "" : ""),
onTap: () async {
await _chooseWillPopNotice(context);
setState(() {});
},
);
},
);
}