hyzp_ybqx-Commit128:解决禁用后,重启App无法启动后台定时提醒的问题
This commit is contained in:
@@ -95,19 +95,15 @@ class _TabsState extends State<Tabs> {
|
||||
// setRemindTimer();
|
||||
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
FlutterBackgroundService.initialize(onStart).then((value) async {
|
||||
if (g_bVoiceRemind) {
|
||||
doRemind();
|
||||
} else {
|
||||
while(true) {
|
||||
if (await FlutterBackgroundService().isServiceRunning()) {
|
||||
FlutterBackgroundService().sendData({"action": "stopService"});
|
||||
print("stopService");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
FlutterBackgroundService.initialize(onStart);
|
||||
if (g_bVoiceRemind) {
|
||||
doRemind();
|
||||
} else {
|
||||
Future.delayed(Duration(seconds: 1), () {
|
||||
FlutterBackgroundService().sendData({"action": "stopService"});
|
||||
print('stopService');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@@ -38,8 +38,7 @@ class _LoginPageState extends State<page7_setRemind> {
|
||||
////////
|
||||
static onNullFun() {}
|
||||
|
||||
Widget _getListTile(
|
||||
title, {
|
||||
Widget _getListTile(title, {
|
||||
String leadPath = '',
|
||||
Color leadColor,
|
||||
Color textColor,
|
||||
@@ -55,20 +54,20 @@ class _LoginPageState extends State<page7_setRemind> {
|
||||
ListTile(
|
||||
leading: bBadge
|
||||
? Badge(
|
||||
position: BadgePosition.topEnd(top: -7, end: -12),
|
||||
badgeContent: null,
|
||||
child: Image.asset(
|
||||
leadPath,
|
||||
height: ScreenUtil().setHeight(78),
|
||||
fit: BoxFit.fitHeight,
|
||||
// color: leadColor, // 无效
|
||||
),
|
||||
)
|
||||
position: BadgePosition.topEnd(top: -7, end: -12),
|
||||
badgeContent: null,
|
||||
child: Image.asset(
|
||||
leadPath,
|
||||
height: ScreenUtil().setHeight(78),
|
||||
fit: BoxFit.fitHeight,
|
||||
// color: leadColor, // 无效
|
||||
),
|
||||
)
|
||||
: Image.asset(
|
||||
leadPath,
|
||||
height: ScreenUtil().setHeight(78),
|
||||
fit: BoxFit.fitHeight,
|
||||
),
|
||||
leadPath,
|
||||
height: ScreenUtil().setHeight(78),
|
||||
fit: BoxFit.fitHeight,
|
||||
),
|
||||
title: Text(title, style: TextStyle(fontSize: size, color: textColor)),
|
||||
trailing: trailWidget,
|
||||
contentPadding: EdgeInsets.symmetric(horizontal: 20.0, vertical: 0),
|
||||
@@ -122,7 +121,9 @@ class _LoginPageState extends State<page7_setRemind> {
|
||||
text: remindGap.toString(),
|
||||
// 保持光标在最后
|
||||
selection: TextSelection.fromPosition(TextPosition(
|
||||
affinity: TextAffinity.downstream, offset: remindGap.toString().length)))),
|
||||
affinity: TextAffinity.downstream, offset: remindGap
|
||||
.toString()
|
||||
.length)))),
|
||||
maxLines: 1,
|
||||
keyboardType: TextInputType.number,
|
||||
decoration: InputDecoration(
|
||||
@@ -240,7 +241,9 @@ class _LoginPageState extends State<page7_setRemind> {
|
||||
color: Colors.blueAccent,
|
||||
onTop: () async {
|
||||
if (g_bVoiceRemind != bVoiceRemind || g_remindGap != remindGap) {
|
||||
if (await FlutterBackgroundService().isServiceRunning()) {
|
||||
var isRuning = await FlutterBackgroundService().isServiceRunning();
|
||||
print("isRuning = $isRuning");
|
||||
if (isRuning) {
|
||||
FlutterBackgroundService().sendData({"action": "stopService"});
|
||||
}
|
||||
|
||||
@@ -253,13 +256,10 @@ class _LoginPageState extends State<page7_setRemind> {
|
||||
await Storage.setInt('nRemindGap', g_remindGap);
|
||||
|
||||
if (bVoiceRemind) {
|
||||
while (true) {
|
||||
var isRunning = await FlutterBackgroundService().isServiceRunning();
|
||||
if (!isRunning) {
|
||||
await FlutterBackgroundService.initialize(onStart);
|
||||
myPlayVoiceRemind();
|
||||
break;
|
||||
}
|
||||
var isRunning = await FlutterBackgroundService().isServiceRunning();
|
||||
if (!isRunning) {
|
||||
await FlutterBackgroundService.initialize(onStart);
|
||||
doRemind();
|
||||
}
|
||||
} else {
|
||||
myPlayClick();
|
||||
|
||||
Reference in New Issue
Block a user