I am using new_vesrion ^0.3.1 package in flutter to display alert dialog for showing to update the app if new version is available on store of flutter app but I am getting below written exception:
[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): E/flutter ( 5988): #2 _SplashScreenState._checkVersion (package:cardicare/appScreens/Splash_Screen.dart:124:20)
Below I have given my code written for showing alert dialog for new updates of flutter app:
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 update your app from " "${status.localVersion}" " to " "${status.storeVersion}",
allowDismissal: false,
dismissAction: ()
{
SystemNavigator.pop();
},
updateButtonText: "Let's Update"
);
}
print("app version on Device " "${status.localVersion}");
print("app version on store " "${status.storeVersion}");
}
} And _checkVersion() method is called in initState() of Splash screen. So please help me to solve this issue.
CodePudding user response:
If your app is not released yet it must be throwing an error
Try adding a try catch and if it fails then dont show the pop up
String storeVersion = "";
try{
storeVersion = status.storeVersion;
}catch(e){}
CodePudding user response:
I think i find the problem, i look into the library and compare to the return from google if u send GET to [https://play.google.com/store/apps/details?id=APP_ID&hl=en]
I think google have changed their return, before the version was returning on the ds:4 script, but now it returns at the ds:5
If u change the line 183 from the new_version.dart to
(elm) => elm.text.contains('key: \'ds:5\''),
The erros is gone, i think they have to update the library