openAppStore method

Future<bool> openAppStore({
  1. String? packageName,
  2. String? marketPackageName,
  3. bool androidUseIntent = true,
  4. String? appId,
  5. LaunchMode mode = LaunchMode.platformDefault,
  6. WebViewConfiguration webViewConfiguration = const WebViewConfiguration(),
  7. String? webOnlyWindowName,
})

Implementation

Future<bool> openAppStore({
  /// android use
  String? packageName,

  /// 指定打开应用商店的报名
  String? marketPackageName,

  /// android use intent launch
  bool androidUseIntent = true,

  ///  ios macos use
  String? appId,
  LaunchMode mode = LaunchMode.platformDefault,
  WebViewConfiguration webViewConfiguration = const WebViewConfiguration(),
  String? webOnlyWindowName,
}) async {
  if ((isIOS || isMacOS) && appId.isNotEmptyOrNull) {
    final String url = 'itms-apps://itunes.apple.com/us/app/$appId';
    return await openUrl(url,
        mode: mode,
        webOnlyWindowName: webOnlyWindowName,
        webViewConfiguration: webViewConfiguration);
  } else if (isAndroid && packageName.isNotEmptyOrNull) {
    final String url = 'market://details?id=$packageName';
    if (androidUseIntent) {
      await AndroidAppMarketIntent(
              packageName: packageName!, package: marketPackageName)
          .launch();
      return true;
    } else {
      return await openUrl(url,
          mode: mode,
          webOnlyWindowName: webOnlyWindowName,
          webViewConfiguration: webViewConfiguration);
    }
  }
  return false;
}