upgrade static method

dynamic upgrade(
  1. BuildContext context,
  2. Future<AppUpgradeInfo> future, {
  3. TextStyle? titleStyle,
  4. TextStyle? versionStyle,
  5. TextStyle? contentStyle,
  6. EdgeInsets? contentPadding,
  7. String? cancelText,
  8. TextStyle? cancelTextStyle,
  9. String? okText,
  10. TextStyle? okTextStyle,
  11. List<Color>? okBackgroundColors,
  12. Color? progressBarColor,
  13. double borderRadius = 20.0,
  14. String? iosAppId,
  15. AppMarketInfo? appMarketInfo,
  16. DividerThemeData? dividerTheme,
  17. DownloadProgressCallback? downloadProgress,
  18. DownloadStatusChangeCallback? downloadStatusChange,
  19. VoidCallback? onCancel,
  20. VoidCallback? onOk,
  21. bool? beta,
})

Implementation

static upgrade(
  BuildContext context,
  Future<AppUpgradeInfo> future, {
  TextStyle? titleStyle,
  TextStyle? versionStyle,
  TextStyle? contentStyle,
  EdgeInsets? contentPadding,
  String? cancelText,
  TextStyle? cancelTextStyle,
  String? okText,
  TextStyle? okTextStyle,
  List<Color>? okBackgroundColors,
  Color? progressBarColor,
  double borderRadius = 20.0,
  String? iosAppId,
  AppMarketInfo? appMarketInfo,
  DividerThemeData? dividerTheme,
  DownloadProgressCallback? downloadProgress,
  DownloadStatusChangeCallback? downloadStatusChange,
  VoidCallback? onCancel,
  VoidCallback? onOk,
  bool? beta,
}) {
  future.then((AppUpgradeInfo appUpgradeInfo) {
    if (!context.mounted) {
      return;
    }

    showDialog(
      context: context,
      barrierDismissible: false,
      builder: (context) {
        okBackgroundColors ??= [
          Theme.of(context).primaryColor,
          Theme.of(context).primaryColor
        ];

        return DividerTheme(
          data: dividerTheme ?? DividerTheme.of(context),
          child: Dialog(
            shape: RoundedRectangleBorder(
              borderRadius: BorderRadius.all(
                Radius.circular(borderRadius),
              ),
            ),
            child: SimpleUpgradeViewWidget(
              title: appUpgradeInfo.title,
              version: appUpgradeInfo.version,
              contents: appUpgradeInfo.contents,
              titleStyle: titleStyle,
              versionStyle: versionStyle,
              contentStyle: contentStyle,
              contentPadding: contentPadding,
              progressBarColor: progressBarColor,
              borderRadius: borderRadius,
              downloadUrl: appUpgradeInfo.apkDownloadUrl,
              headers: appUpgradeInfo.headers,
              force: appUpgradeInfo.force,
              iosAppId: iosAppId,
              appMarketInfo: appMarketInfo,
              downloadProgress: downloadProgress,
              downloadStatusChange: downloadStatusChange,
              okBackgroundColors: okBackgroundColors,
              cancelTextStyle: cancelTextStyle,
              okTextStyle: okTextStyle,
              cancelText: cancelText,
              onCancel: onCancel,
              okText: okText,
              onOk: onOk,
              beta: beta,
            ),
          ),
        );
      },
    );
  }).catchError((error) {
    debugPrint('$error');
  });
}