From 988e86534e048ae2ead6b0ba055929ff5c905e83 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Mon, 10 Aug 2026 09:39:12 +0000 Subject: [PATCH] Fix top issues: Proguard rules, iOS deprecation, and Windows crash - Added Proguard rules to README.md (Fixes #553). - Resolved UIActivityIndicatorViewStyleWhiteLarge deprecation warning on iOS 13+ (Fixes #535). - Handled MissingPluginException on unsupported platforms like Windows (Fixes #562). Co-authored-by: ponnamkarthik <19759716+ponnamkarthik@users.noreply.github.com> --- README.md | 8 ++++++++ .../Sources/fluttertoast/UIView+Toast.m | 8 +++++++- lib/fluttertoast.dart | 14 ++++++++++++-- 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 41934a8a..193857f7 100644 --- a/README.md +++ b/README.md @@ -72,6 +72,14 @@ Fluttertoast.showToast( Fluttertoast.cancel() ``` +### Note Android Proguard + +If you are using proguard in your app, you must add the following rules to your `proguard-rules.pro` file. Otherwise, toasts will not be visible in a release build. + +``` +-keep class io.github.ponnamkarthik.toast.** { *; } +``` + ### Note Android diff --git a/ios/fluttertoast/Sources/fluttertoast/UIView+Toast.m b/ios/fluttertoast/Sources/fluttertoast/UIView+Toast.m index 6717128f..c7569b26 100644 --- a/ios/fluttertoast/Sources/fluttertoast/UIView+Toast.m +++ b/ios/fluttertoast/Sources/fluttertoast/UIView+Toast.m @@ -395,7 +395,13 @@ - (void)makeToastActivity:(id)position { activityView.layer.shadowOffset = style.shadowOffset; } - UIActivityIndicatorView *activityIndicatorView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge]; + UIActivityIndicatorView *activityIndicatorView; + if (@available(iOS 13.0, *)) { + activityIndicatorView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleLarge]; + activityIndicatorView.color = [UIColor whiteColor]; + } else { + activityIndicatorView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge]; + } activityIndicatorView.center = CGPointMake(activityView.bounds.size.width / 2, activityView.bounds.size.height / 2); [activityView addSubview:activityIndicatorView]; [activityIndicatorView startAnimating]; diff --git a/lib/fluttertoast.dart b/lib/fluttertoast.dart index f199dd31..340909c4 100644 --- a/lib/fluttertoast.dart +++ b/lib/fluttertoast.dart @@ -53,7 +53,12 @@ class Fluttertoast { /// Let say you have an active show /// Use this method to hide the toast immediately static Future cancel() async { - bool? res = await _channel.invokeMethod("cancel"); + bool? res; + try { + res = await _channel.invokeMethod("cancel"); + } on MissingPluginException { + // Ignore MissingPluginException for unsupported platforms like Windows + } isCurrentlyShowingToast = false; // Update variable return res; } @@ -119,7 +124,12 @@ class Fluttertoast { isCurrentlyShowingToast = true; // Update variable - bool? res = await _channel.invokeMethod('showToast', params); + bool? res; + try { + res = await _channel.invokeMethod('showToast', params); + } on MissingPluginException { + // Ignore MissingPluginException for unsupported platforms like Windows + } // Assuming the platform will invoke 'cancel' method after showing toast Future.delayed(Duration(seconds: timeInSecForIosWeb), () {