Skip to content

Kanyade/universal-app

Repository files navigation

UniversalApp

Version GitHub license

A utility to open app store links across platforms.

Note that this package is based on the following open source Flutter snippet. This is simply an improved & published version to make it more accessible.

Usage

UniversalApp is a simple class that can be used on all platforms to easily open the stores for the app configuration passed in the parameters.

Future<void> openStore() async {
  final needForSpeedNoLimits = UniversalApp(
    appleAppId: '883393043',
    appleAppCountry: 'us',
    androidPackageName: 'com.ea.game.nfs14_row',
    fallbackFunction: (appStore, playStore, _ /* Huawei App if configured */, _ /* Microsoft Store if configured */) {
      print('App Store URI: ${appStore!.storeLink}');
      print('Play Store URI: ${playStore!.storeLink}');

      return null;
    },
  );

  await needForSpeedNoLimits.open();
}

There are also specific classes, AppStoreApp, PlayStoreApp, HuaweiAppGalleryApp and MicrosoftStoreApp for the respective stores. Each one has a Uri get storeLink; getter to retrieve the link for the app. It is coming from the HasStoreLink mixin which you can also extend yourself for custom cases.

Parameters

Parameter Description
appleAppId The appId of the iOS application.
appleAppCountry The country of the App Store the iOS application is in for the fallbackFunction. Defaults to us.
androidPackageName The package name of the android application. For example com.example.app.
huaweiAppId The appId of the Huawei application. Note that in order to use this on Android, you need to add the logic in determineAndroidStore.
windowsProductId The productId of the Windows application.
determineAndroidStore Optional callback to determine the store to be used on Android. Must be specified in order to use the Huawei implementation or if you have custom use-cases.
fallbackFunction The fallback in case the current platform does not have an app configured in UniversalApp. If it returns null it does not do anything. If a store class is returned the web link of that store will be launched.

Limitation

Even if huaweiAppId is present, you need to determine which store to use yourself via determineAndroidStore. This is in order not to put extra logic & native code to this package for everyone unless it is needed, e.g. checking manufacturer with device_info_plus or manually on native side whether Play Store is present or not.

License

Copyright 2025 Norbert Csörgő

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

About

A utility to open app store links across platforms.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages