'How to automatically update a Flutter Mobile app to newer version when the application is not on play store or app store?

let's say i have a Flutter APK hosted on my website where users can download and install , what i'm interested to know is how possible that the application can check for newer version when the app lunches and if true a progress bar appears showing the automatic updating of the application from the server (not play store or app store) ? .
here is a company that do exactly the mentioned above meaning :

  • download the apk from there server
  • whenever a new version is released the app will update from their server

any ideas how to achieve this ?



Solution 1:[1]

i found this package ota_update 2.4.1,looks very promising for updating a Flutter from a remote hosted Apk here is an exmple :

   // IMPORT PACKAGE
    import 'package:ota_update/ota_update.dart';
    
      // RUN OTA UPDATE 
      // START LISTENING FOR DOWNLOAD PROGRESS REPORTING EVENTS
      try {
          //LINK CONTAINS APK OF FLUTTER HELLO WORLD FROM FLUTTER SDK EXAMPLES
          OtaUpdate()
              .execute(
            'https://internal1.4q.sk/flutter_hello_world.apk',
            // OPTIONAL
            destinationFilename: 'flutter_hello_world.apk',
            //OPTIONAL, ANDROID ONLY - ABILITY TO VALIDATE CHECKSUM OF FILE:
            sha256checksum: "d6da28451a1e15cf7a75f2c3f151befad3b80ad0bb232ab15c20897e54f21478",
          ).listen(
            (OtaEvent event) {
              setState(() => currentEvent = event);
            },
          );
      } catch (e) {
          print('Failed to make OTA update. Details: $e');
      }

any other proposed solutions are welcome.

Solution 2:[2]

ota_update(as mentioned by @Asmoun) looks good to me for this use case, alternative would be to download APK using something like flutter_downloader and start intent for install using android_intent.

Moreover for fetching latest version code or download URL, I suggest you use firebase_remote_config.

Solution 3:[3]

You can write a service on the server-side that check the current version with the old version in the splash screen. First, you must send the current version to the server and check version uploading with the old version uploaded then if there are a new version return alert and apk for download

Solution 4:[4]

If you need this for Android only, you could use the in_app_update library.

If you need functionality for iOS too, the above library recommends upgrader that does something similar but not the same.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Asmoun
Solution 2 Asmoun
Solution 3 hosein moradi
Solution 4 S.V.