From 889a6f549da1f273f758193e95488b35120c396e Mon Sep 17 00:00:00 2001 From: OlehMarch Date: Thu, 19 Feb 2026 20:27:18 +0100 Subject: [PATCH 01/10] added `Intent.FLAG_ACTIVITY_NEW_TASK` to `Share.startActivity` --- .../src/main/kotlin/dev/fluttercommunity/plus/share/Share.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/share_plus/share_plus/android/src/main/kotlin/dev/fluttercommunity/plus/share/Share.kt b/packages/share_plus/share_plus/android/src/main/kotlin/dev/fluttercommunity/plus/share/Share.kt index fb6a107988..f87014ebff 100644 --- a/packages/share_plus/share_plus/android/src/main/kotlin/dev/fluttercommunity/plus/share/Share.kt +++ b/packages/share_plus/share_plus/android/src/main/kotlin/dev/fluttercommunity/plus/share/Share.kt @@ -157,6 +157,7 @@ internal class Share( if (withResult) { activity!!.startActivityForResult(intent, ShareSuccessManager.ACTIVITY_CODE) } else { + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) activity!!.startActivity(intent) } } else { From c35d1071846c272e016965266dd9d836524950f2 Mon Sep 17 00:00:00 2001 From: OlehMarch Date: Thu, 19 Feb 2026 20:38:21 +0100 Subject: [PATCH 02/10] added `Intent.FLAG_ACTIVITY_MULTIPLE_TASK` to `Share.startActivity` --- .../dev/fluttercommunity/plus/share/Share.kt | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/packages/share_plus/share_plus/android/src/main/kotlin/dev/fluttercommunity/plus/share/Share.kt b/packages/share_plus/share_plus/android/src/main/kotlin/dev/fluttercommunity/plus/share/Share.kt index f87014ebff..86cc868b9e 100644 --- a/packages/share_plus/share_plus/android/src/main/kotlin/dev/fluttercommunity/plus/share/Share.kt +++ b/packages/share_plus/share_plus/android/src/main/kotlin/dev/fluttercommunity/plus/share/Share.kt @@ -153,22 +153,23 @@ internal class Share( } private fun startActivity(intent: Intent, withResult: Boolean) { - if (activity != null) { - if (withResult) { - activity!!.startActivityForResult(intent, ShareSuccessManager.ACTIVITY_CODE) - } else { - intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) - activity!!.startActivity(intent) - } + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) + intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK) + + if (activity != null) { + if (withResult) { + activity!!.startActivityForResult(intent, ShareSuccessManager.ACTIVITY_CODE) } else { - intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) - if (withResult) { - // We need to cancel the callback to avoid deadlocking on the Dart side - manager.unavailable() - } - context.startActivity(intent) + activity!!.startActivity(intent) + } + } else { + if (withResult) { + // We need to cancel the callback to avoid deadlocking on the Dart side + manager.unavailable() } + context.startActivity(intent) } +} @Throws(IOException::class) private fun getUrisForPaths(paths: List): ArrayList { From f0d969e486c3e1632a22a5b1f40996d50c7e0f60 Mon Sep 17 00:00:00 2001 From: OlehMarch Date: Thu, 19 Feb 2026 20:40:35 +0100 Subject: [PATCH 03/10] cleanup --- .../dev/fluttercommunity/plus/share/Share.kt | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/packages/share_plus/share_plus/android/src/main/kotlin/dev/fluttercommunity/plus/share/Share.kt b/packages/share_plus/share_plus/android/src/main/kotlin/dev/fluttercommunity/plus/share/Share.kt index 86cc868b9e..4c3a5e39eb 100644 --- a/packages/share_plus/share_plus/android/src/main/kotlin/dev/fluttercommunity/plus/share/Share.kt +++ b/packages/share_plus/share_plus/android/src/main/kotlin/dev/fluttercommunity/plus/share/Share.kt @@ -153,23 +153,23 @@ internal class Share( } private fun startActivity(intent: Intent, withResult: Boolean) { - intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) - intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK) + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) + intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK) - if (activity != null) { - if (withResult) { - activity!!.startActivityForResult(intent, ShareSuccessManager.ACTIVITY_CODE) + if (activity != null) { + if (withResult) { + activity!!.startActivityForResult(intent, ShareSuccessManager.ACTIVITY_CODE) + } else { + activity!!.startActivity(intent) + } } else { - activity!!.startActivity(intent) - } - } else { - if (withResult) { - // We need to cancel the callback to avoid deadlocking on the Dart side - manager.unavailable() + if (withResult) { + // We need to cancel the callback to avoid deadlocking on the Dart side + manager.unavailable() + } + context.startActivity(intent) } - context.startActivity(intent) } -} @Throws(IOException::class) private fun getUrisForPaths(paths: List): ArrayList { From cbe6b06e45f1d5dec9d7a36461e606dea33eabc1 Mon Sep 17 00:00:00 2001 From: OlehMarch Date: Wed, 25 Feb 2026 15:56:38 +0100 Subject: [PATCH 04/10] added useNewTask for android share --- .../kotlin/dev/fluttercommunity/plus/share/Share.kt | 11 ++++++++--- .../lib/method_channel/method_channel_share.dart | 1 + .../lib/platform_interface/share_plus_platform.dart | 7 +++++++ 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/packages/share_plus/share_plus/android/src/main/kotlin/dev/fluttercommunity/plus/share/Share.kt b/packages/share_plus/share_plus/android/src/main/kotlin/dev/fluttercommunity/plus/share/Share.kt index 4c3a5e39eb..e8db456607 100644 --- a/packages/share_plus/share_plus/android/src/main/kotlin/dev/fluttercommunity/plus/share/Share.kt +++ b/packages/share_plus/share_plus/android/src/main/kotlin/dev/fluttercommunity/plus/share/Share.kt @@ -66,6 +66,7 @@ internal class Share( val paths = (arguments["paths"] as List<*>?)?.filterIsInstance() val mimeTypes = (arguments["mimeTypes"] as List<*>?)?.filterIsInstance() val fileUris = paths?.let { getUrisForPaths(paths) } + val useNewTask = arguments["useNewTask"] as Boolean?; // Create Share Intent val shareIntent = Intent() @@ -148,14 +149,18 @@ internal class Share( } } + if (useNewTask) { + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) + intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK) + } else if (activity == null) { + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) + } + // Launch share intent startActivity(chooserIntent, withResult) } private fun startActivity(intent: Intent, withResult: Boolean) { - intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) - intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK) - if (activity != null) { if (withResult) { activity!!.startActivityForResult(intent, ShareSuccessManager.ACTIVITY_CODE) diff --git a/packages/share_plus/share_plus_platform_interface/lib/method_channel/method_channel_share.dart b/packages/share_plus/share_plus_platform_interface/lib/method_channel/method_channel_share.dart index c4ece10e00..256de1d3ff 100644 --- a/packages/share_plus/share_plus_platform_interface/lib/method_channel/method_channel_share.dart +++ b/packages/share_plus/share_plus_platform_interface/lib/method_channel/method_channel_share.dart @@ -41,6 +41,7 @@ class MethodChannelShare extends SharePlatform { if (params.subject != null) 'subject': params.subject, if (params.title != null) 'title': params.title, if (params.uri != null) 'uri': params.uri.toString(), + 'useNewTask': params.useNewTask, }; if (params.sharePositionOrigin != null) { diff --git a/packages/share_plus/share_plus_platform_interface/lib/platform_interface/share_plus_platform.dart b/packages/share_plus/share_plus_platform_interface/lib/platform_interface/share_plus_platform.dart index 40ceee27b6..26b4341b39 100644 --- a/packages/share_plus/share_plus_platform_interface/lib/platform_interface/share_plus_platform.dart +++ b/packages/share_plus/share_plus_platform_interface/lib/platform_interface/share_plus_platform.dart @@ -142,6 +142,12 @@ class ShareParams { /// Parameter ignored on other platforms. final List? excludedCupertinoActivities; + /// Whether to use a new task when sharing on Android. + /// + /// * Supported platforms: Android + /// Parameter ignored on other platforms. + final bool useNewTask; + ShareParams({ this.text, this.subject, @@ -154,6 +160,7 @@ class ShareParams { this.downloadFallbackEnabled = true, this.mailToFallbackEnabled = true, this.excludedCupertinoActivities, + this.useNewTask = false, }); } From 044efc9373813ace69fb00cc340039a683f745f8 Mon Sep 17 00:00:00 2001 From: OlehMarch Date: Wed, 25 Feb 2026 15:58:57 +0100 Subject: [PATCH 05/10] bumped share_plus_platform_interface version --- packages/share_plus/share_plus_platform_interface/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/share_plus/share_plus_platform_interface/pubspec.yaml b/packages/share_plus/share_plus_platform_interface/pubspec.yaml index 105531d888..b593cf3e02 100644 --- a/packages/share_plus/share_plus_platform_interface/pubspec.yaml +++ b/packages/share_plus/share_plus_platform_interface/pubspec.yaml @@ -1,6 +1,6 @@ name: share_plus_platform_interface description: A common platform interface for the share_plus plugin. -version: 6.1.0 +version: 6.1.1 homepage: https://github.com/fluttercommunity/plus_plugins repository: https://github.com/fluttercommunity/plus_plugins/tree/main/packages/ From 6b73b0259c94afa2d94ed838715d2bd281d16384 Mon Sep 17 00:00:00 2001 From: OlehMarch Date: Wed, 25 Feb 2026 16:01:00 +0100 Subject: [PATCH 06/10] bumped share_plus version --- packages/share_plus/share_plus/pubspec.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/share_plus/share_plus/pubspec.yaml b/packages/share_plus/share_plus/pubspec.yaml index 4b951845d1..c7b3eeb58d 100644 --- a/packages/share_plus/share_plus/pubspec.yaml +++ b/packages/share_plus/share_plus/pubspec.yaml @@ -1,6 +1,6 @@ name: share_plus description: Flutter plugin for sharing content via the platform share UI, using the ACTION_SEND intent on Android and UIActivityViewController on iOS. -version: 12.0.1 +version: 12.0.2 homepage: https://github.com/fluttercommunity/plus_plugins repository: https://github.com/fluttercommunity/plus_plugins/tree/main/packages/share_plus/share_plus issue_tracker: https://github.com/fluttercommunity/plus_plugins/labels/share_plus @@ -35,7 +35,7 @@ dependencies: sdk: flutter flutter_web_plugins: sdk: flutter - share_plus_platform_interface: ^6.1.0 + share_plus_platform_interface: ^6.1.1 file: ">=6.1.4 <8.0.0" url_launcher_web: ^2.3.2 url_launcher_windows: ^3.1.2 From 5669ef00f9501e436804297dce84cd02845c4eb4 Mon Sep 17 00:00:00 2001 From: OlehMarch Date: Wed, 25 Feb 2026 16:04:50 +0100 Subject: [PATCH 07/10] fixed type typo --- .../src/main/kotlin/dev/fluttercommunity/plus/share/Share.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/share_plus/share_plus/android/src/main/kotlin/dev/fluttercommunity/plus/share/Share.kt b/packages/share_plus/share_plus/android/src/main/kotlin/dev/fluttercommunity/plus/share/Share.kt index e8db456607..7f40ddbda6 100644 --- a/packages/share_plus/share_plus/android/src/main/kotlin/dev/fluttercommunity/plus/share/Share.kt +++ b/packages/share_plus/share_plus/android/src/main/kotlin/dev/fluttercommunity/plus/share/Share.kt @@ -66,7 +66,7 @@ internal class Share( val paths = (arguments["paths"] as List<*>?)?.filterIsInstance() val mimeTypes = (arguments["mimeTypes"] as List<*>?)?.filterIsInstance() val fileUris = paths?.let { getUrisForPaths(paths) } - val useNewTask = arguments["useNewTask"] as Boolean?; + val useNewTask = arguments["useNewTask"] as Boolean; // Create Share Intent val shareIntent = Intent() From c37ff78d2e08ee73425570ec6abb9a8d652f6364 Mon Sep 17 00:00:00 2001 From: OlehMarch Date: Wed, 25 Feb 2026 16:06:38 +0100 Subject: [PATCH 08/10] fixed intent typo --- .../main/kotlin/dev/fluttercommunity/plus/share/Share.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/share_plus/share_plus/android/src/main/kotlin/dev/fluttercommunity/plus/share/Share.kt b/packages/share_plus/share_plus/android/src/main/kotlin/dev/fluttercommunity/plus/share/Share.kt index 7f40ddbda6..c29cca474f 100644 --- a/packages/share_plus/share_plus/android/src/main/kotlin/dev/fluttercommunity/plus/share/Share.kt +++ b/packages/share_plus/share_plus/android/src/main/kotlin/dev/fluttercommunity/plus/share/Share.kt @@ -150,10 +150,10 @@ internal class Share( } if (useNewTask) { - intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) - intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK) + chooserIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) + chooserIntent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK) } else if (activity == null) { - intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) + chooserIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) } // Launch share intent From 8237036b7be0150c09f32be61215b537c77ce41c Mon Sep 17 00:00:00 2001 From: OlehMarch Date: Thu, 26 Feb 2026 09:34:55 +0100 Subject: [PATCH 09/10] cleanup for MR --- packages/share_plus/share_plus/pubspec.yaml | 4 ++-- .../share_plus/share_plus_platform_interface/pubspec.yaml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/share_plus/share_plus/pubspec.yaml b/packages/share_plus/share_plus/pubspec.yaml index c7b3eeb58d..4b951845d1 100644 --- a/packages/share_plus/share_plus/pubspec.yaml +++ b/packages/share_plus/share_plus/pubspec.yaml @@ -1,6 +1,6 @@ name: share_plus description: Flutter plugin for sharing content via the platform share UI, using the ACTION_SEND intent on Android and UIActivityViewController on iOS. -version: 12.0.2 +version: 12.0.1 homepage: https://github.com/fluttercommunity/plus_plugins repository: https://github.com/fluttercommunity/plus_plugins/tree/main/packages/share_plus/share_plus issue_tracker: https://github.com/fluttercommunity/plus_plugins/labels/share_plus @@ -35,7 +35,7 @@ dependencies: sdk: flutter flutter_web_plugins: sdk: flutter - share_plus_platform_interface: ^6.1.1 + share_plus_platform_interface: ^6.1.0 file: ">=6.1.4 <8.0.0" url_launcher_web: ^2.3.2 url_launcher_windows: ^3.1.2 diff --git a/packages/share_plus/share_plus_platform_interface/pubspec.yaml b/packages/share_plus/share_plus_platform_interface/pubspec.yaml index b593cf3e02..105531d888 100644 --- a/packages/share_plus/share_plus_platform_interface/pubspec.yaml +++ b/packages/share_plus/share_plus_platform_interface/pubspec.yaml @@ -1,6 +1,6 @@ name: share_plus_platform_interface description: A common platform interface for the share_plus plugin. -version: 6.1.1 +version: 6.1.0 homepage: https://github.com/fluttercommunity/plus_plugins repository: https://github.com/fluttercommunity/plus_plugins/tree/main/packages/ From d3eb0c28c6c34473995a4400093d272a0a3dcc1f Mon Sep 17 00:00:00 2001 From: OlehMarch Date: Thu, 26 Feb 2026 09:49:52 +0100 Subject: [PATCH 10/10] fixed tests --- .../test/share_plus_platform_interface_test.dart | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/share_plus/share_plus_platform_interface/test/share_plus_platform_interface_test.dart b/packages/share_plus/share_plus_platform_interface/test/share_plus_platform_interface_test.dart index 18f22cf889..da1ef5dce3 100644 --- a/packages/share_plus/share_plus_platform_interface/test/share_plus_platform_interface_test.dart +++ b/packages/share_plus/share_plus_platform_interface/test/share_plus_platform_interface_test.dart @@ -71,6 +71,7 @@ void main() { ); verify(mockChannel.invokeMethod('share', { 'uri': 'https://pub.dev/packages/share_plus', + 'useNewTask': false, 'originX': 1.0, 'originY': 2.0, 'originWidth': 3.0, @@ -89,6 +90,7 @@ void main() { verify(mockChannel.invokeMethod('share', { 'text': 'some text to share', 'subject': 'some subject to share', + 'useNewTask': false, 'originX': 1.0, 'originY': 2.0, 'originWidth': 3.0, @@ -112,6 +114,7 @@ void main() { 'mimeTypes': ['image/png'], 'subject': 'some subject to share', 'text': 'some text to share', + 'useNewTask': false, 'originX': 1.0, 'originY': 2.0, 'originWidth': 3.0, @@ -127,6 +130,7 @@ void main() { verify(mockChannel.invokeMethod('share', { 'paths': [fd.path], 'mimeTypes': ['image/png'], + 'useNewTask': false, })); }); }); @@ -141,6 +145,7 @@ void main() { verify(mockChannel.invokeMethod('share', { 'paths': [fd.path], 'mimeTypes': ['*/*'], + 'useNewTask': false, })); }); }); @@ -190,6 +195,7 @@ void main() { verify(mockChannel.invokeMethod('share', { 'text': 'some text to share', 'subject': 'some subject to share', + 'useNewTask': false, 'originX': 1.0, 'originY': 2.0, 'originWidth': 3.0, @@ -206,6 +212,7 @@ void main() { verify(mockChannel.invokeMethod('share', { 'paths': [fd.path], 'mimeTypes': ['image/png'], + 'useNewTask': false, })); expect(result, success); });