1111
This commit is contained in:
parent
165e59d5fe
commit
f46f53962f
|
|
@ -495,12 +495,23 @@ class MethodChannelAppUpgradePlugin extends AppUpgradePluginPlatform {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
debugPrint('当前APP没有上架当前设备对应的应用市场');
|
debugPrint('当前APP没有上架当前设备对应的应用市场');
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
if (context.mounted) {
|
||||||
SnackBar(
|
try {
|
||||||
content: Text('当前APP没有上架当前设备对应的应用市场'),
|
final scaffoldMessenger = ScaffoldMessenger.maybeOf(context);
|
||||||
duration: Duration(seconds: 2),
|
if (scaffoldMessenger != null) {
|
||||||
),
|
scaffoldMessenger.showSnackBar(
|
||||||
);
|
SnackBar(
|
||||||
|
content: Text('当前APP没有上架当前设备对应的应用市场'),
|
||||||
|
duration: Duration(seconds: 2),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
debugPrint('提示(无Scaffold): 当前APP没有上架当前设备对应的应用市场');
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
debugPrint('显示提示失败: $e');
|
||||||
|
}
|
||||||
|
}
|
||||||
// Fluttertoast.showToast(msg: '当前APP没有上架当前设备对应的应用市场');
|
// Fluttertoast.showToast(msg: '当前APP没有上架当前设备对应的应用市场');
|
||||||
return false;
|
return false;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
|
||||||
|
|
@ -524,12 +524,31 @@ class AppUpgradeSimple {
|
||||||
if (effectiveConfig.customToast != null) {
|
if (effectiveConfig.customToast != null) {
|
||||||
effectiveConfig.customToast!(message);
|
effectiveConfig.customToast!(message);
|
||||||
} else {
|
} else {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
// 检查 context 是否有效且有 Scaffold
|
||||||
SnackBar(
|
if (!context.mounted) {
|
||||||
content: Text(message),
|
debugPrint('Toast消息(context已卸载): $message');
|
||||||
duration: Duration(seconds: 2),
|
return;
|
||||||
),
|
}
|
||||||
);
|
|
||||||
|
try {
|
||||||
|
// 尝试获取 ScaffoldMessenger,如果失败则使用 debugPrint
|
||||||
|
final scaffoldMessenger = ScaffoldMessenger.maybeOf(context);
|
||||||
|
if (scaffoldMessenger != null) {
|
||||||
|
scaffoldMessenger.showSnackBar(
|
||||||
|
SnackBar(
|
||||||
|
content: Text(message),
|
||||||
|
duration: Duration(seconds: 2),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
// 如果没有 Scaffold,使用 debugPrint 作为后备方案
|
||||||
|
debugPrint('Toast消息(无Scaffold): $message');
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
// 如果出现任何错误,使用 debugPrint 作为后备方案
|
||||||
|
debugPrint('显示Toast失败: $e');
|
||||||
|
debugPrint('Toast消息: $message');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -267,9 +267,19 @@ class PermissionHelper {
|
||||||
message = '未授予安装权限,无法完成更新。';
|
message = '未授予安装权限,无法完成更新。';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
try {
|
||||||
SnackBar(content: Text(message)),
|
final scaffoldMessenger = ScaffoldMessenger.maybeOf(context);
|
||||||
);
|
if (scaffoldMessenger != null) {
|
||||||
|
scaffoldMessenger.showSnackBar(
|
||||||
|
SnackBar(content: Text(message)),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
debugPrint('权限提示(无Scaffold): $message');
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
debugPrint('显示权限提示失败: $e');
|
||||||
|
debugPrint('权限提示: $message');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return status == InstallPermissionStatus.granted;
|
return status == InstallPermissionStatus.granted;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue