Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

new_version package in flutter returns RangeError (index): Invalid value: Valid value range is empty: 1

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): <asynchronous suspension>
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.

like image 876
Ganesh Avatar asked Jun 08 '26 23:06

Ganesh


1 Answers

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

@Edit

I have download the file new_version from GitHub and paste into my project, make some changes and works fine

like image 188
E. Greeff Avatar answered Jun 11 '26 12:06

E. Greeff