我在 flutter 中使用 new_vesrion ^0.3.1 包来显示警报对话框,如果 flutter 应用程序商店中有新版本可用,则显示更新应用程序,但我收到以下书面异常:
[ERROR:flutter/lib/ui/ui_dart_state.cc(198)] Unhandled Exception: RangeError (index): Invalid value: Valid value range is empty: 1
E/flutter ( 5988): #0 List.[] (dart:core-patch/growable_array.dart:264:36)
E/flutter ( 5988): #1 NewVersion._getAndroidStoreVersion (package:new_version/new_version.dart:195:26)
E/flutter ( 5988): <asynchronous suspension>
E/flutter ( 5988): #2 _SplashScreenState._checkVersion (package:cardicare/appScreens/Splash_Screen.dart:124:20)
Run Code Online (Sandbox Code Playgroud)
下面我给出了为显示颤振应用程序新更新的警报对话框而编写的代码:
void _checkVersion() async
{
final newVersion = NewVersion
(
androidId: androidAppId,
iOSId: iOSAppId
);
final status = await newVersion.getVersionStatus();
if(status!=null)
{
if(status.canUpdate)
{
newVersion.showUpdateDialog
(
context: context,
versionStatus: status,
dialogTitle: "Update!!!",
//dismissButtonText: "Skip",
dialogText: "Please …Run Code Online (Sandbox Code Playgroud)