upgrade static method

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

Implementation

static upgrade(
  BuildContext context,
  Future<AppUpgradeInfo> future, {
  TextStyle? titleStyle,
  TextStyle? contentStyle,
  String? cancelText,
  TextStyle? cancelTextStyle,
  String? okText,
  TextStyle? okTextStyle,
  List<Color>? okBackgroundColors,
  Color? progressBarColor,
  double borderRadius = 20.0,
  String? iosAppId,
  AppMarketInfo? appMarketInfo,
  VoidCallback? onCancel,
  VoidCallback? onOk,
  DownloadProgressCallback? downloadProgress,
  DownloadStatusChangeCallback? downloadStatusChange,
}) {
  future.then((AppUpgradeInfo appUpgradeInfo) {
    showDialog(
        context: context,
        barrierDismissible: false,
        builder: (context) {
          okBackgroundColors ??= [
            Theme.of(context).primaryColor,
            Theme.of(context).primaryColor
          ];

          return PopScope(
            child: Dialog(
              shape: RoundedRectangleBorder(
                borderRadius: BorderRadius.all(
                  Radius.circular(borderRadius),
                ),
              ),
              child: SimpleUpgradeViewWidget(
                title: appUpgradeInfo.title,
                contents: appUpgradeInfo.contents,
                titleStyle: titleStyle,
                contentStyle: contentStyle,
                progressBarColor: progressBarColor,
                borderRadius: borderRadius,
                downloadUrl: appUpgradeInfo.apkDownloadUrl,
                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,
              ),
            ),
          );
        });
  }).catchError((error) {
    debugPrint('$error');
  });
}