upgrader icon indicating copy to clipboard operation
upgrader copied to clipboard

Avoid exposing `version` dependency to client app since PR #513

Open BriceFab opened this issue 3 months ago • 0 comments

Hello @larryaasen,

Since PR #513, the client application is required to explicitly add the version package as a dependency in order to use UpgraderAppcastStore, due to the osVersion parameter expecting a Version object.

This creates an unnecessary burden on the client, as the parsing could be handled internally within the library.

Suggested Improvement

To avoid forcing the client app to import the version package, consider handling the version parsing internally.

For example, this logic could be encapsulated inside UpgraderAppcastStore:

Future<Version> getCurrentOSVersion(String? osVersionString) async {
  Version osVersion;
  try {
    osVersion = osVersionString?.isNotEmpty == true
        ? Version.parse(osVersionString!)
        : Version(0, 0, 0);
  } catch (e) {
    osVersion = Version(0, 0, 0);
  }
  return osVersion;
}

Then, from the client side, we could simply pass the string:

_upgrader = Upgrader(
  debugLogging: kDebugMode,
  storeController: UpgraderStoreController(
    onAndroid: () => UpgraderAppcastStore(
      appcastURL: '$baseUrl/$languageCode/appcast/android.xml',
      osVersion: osVersionString, // Just a String
    ),
    oniOS: () => UpgraderAppcastStore(
      appcastURL: '$baseUrl/$languageCode/appcast/ios.xml',
      osVersion: osVersionString,
    ),
  ),
);

Benefits

  • Keeps the version dependency internal to the upgrader package
  • Simplifies integration for consumers
  • Improves encapsulation and usability

Thanks

BriceFab avatar Sep 16 '25 08:09 BriceFab