From f5edbdb806fa25a614bfdce6a932676a0dc919fe Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 23 Feb 2026 23:07:22 +0000 Subject: [PATCH 1/5] chore(deps): bump win32 in /packages/share_plus/share_plus Bumps [win32](https://github.com/halildurmus/win32) from 5.15.0 to 6.0.0. - [Release notes](https://github.com/halildurmus/win32/releases) - [Commits](https://github.com/halildurmus/win32/compare/v5.15.0...win32-v6.0.0) --- updated-dependencies: - dependency-name: win32 dependency-version: 6.0.0 dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- packages/share_plus/share_plus/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/share_plus/share_plus/pubspec.yaml b/packages/share_plus/share_plus/pubspec.yaml index 4b951845d1..ceb61bdfc5 100644 --- a/packages/share_plus/share_plus/pubspec.yaml +++ b/packages/share_plus/share_plus/pubspec.yaml @@ -43,7 +43,7 @@ dependencies: url_launcher_platform_interface: ^2.3.2 ffi: ^2.1.2 web: ^1.0.0 - win32: ^5.5.3 + win32: ">=5.5.3 <7.0.0" dev_dependencies: flutter_test: From 38e7f495ab8cac59d67d6c3f48f42609323b5b8c Mon Sep 17 00:00:00 2001 From: Volodymyr Date: Tue, 7 Apr 2026 18:35:30 +0300 Subject: [PATCH 2/5] chore(share_plus): Update all dependencies and requirements --- packages/share_plus/share_plus/README.md | 8 +- .../ios/Flutter/AppFrameworkInfo.plist | 2 - .../example/ios/Runner/AppDelegate.swift | 9 +- .../share_plus/example/ios/Runner/Info.plist | 25 ++- .../share_plus/example/lib/main.dart | 5 +- .../lib/src/windows_version_helper.dart | 3 +- packages/share_plus/share_plus/pubspec.yaml | 26 +-- .../pubspec.yaml | 19 +-- .../share_plus_platform_interface_test.dart | 154 +++++++++--------- 9 files changed, 134 insertions(+), 117 deletions(-) diff --git a/packages/share_plus/share_plus/README.md b/packages/share_plus/share_plus/README.md index f8d31d9406..ab5ca73fb1 100644 --- a/packages/share_plus/share_plus/README.md +++ b/packages/share_plus/share_plus/README.md @@ -26,10 +26,10 @@ Sharing files is not supported on Linux. ## Requirements -- Flutter >=3.22.0 -- Dart >=3.4.0 <4.0.0 -- iOS >=12.0 -- macOS >=10.14 +- Flutter >=3.41.6 +- Dart >=3.11.0 <4.0.0 +- iOS >=13.0 +- macOS >=10.15 - Java 17 - Kotlin 2.2.0 - Android Gradle Plugin >=8.12.1 diff --git a/packages/share_plus/share_plus/example/ios/Flutter/AppFrameworkInfo.plist b/packages/share_plus/share_plus/example/ios/Flutter/AppFrameworkInfo.plist index 1dc6cf7652..391a902b2b 100644 --- a/packages/share_plus/share_plus/example/ios/Flutter/AppFrameworkInfo.plist +++ b/packages/share_plus/share_plus/example/ios/Flutter/AppFrameworkInfo.plist @@ -20,7 +20,5 @@ ???? CFBundleVersion 1.0 - MinimumOSVersion - 13.0 diff --git a/packages/share_plus/share_plus/example/ios/Runner/AppDelegate.swift b/packages/share_plus/share_plus/example/ios/Runner/AppDelegate.swift index b636303481..c30b367ec0 100644 --- a/packages/share_plus/share_plus/example/ios/Runner/AppDelegate.swift +++ b/packages/share_plus/share_plus/example/ios/Runner/AppDelegate.swift @@ -1,13 +1,16 @@ -import UIKit import Flutter +import UIKit @main -@objc class AppDelegate: FlutterAppDelegate { +@objc class AppDelegate: FlutterAppDelegate, FlutterImplicitEngineDelegate { override func application( _ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? ) -> Bool { - GeneratedPluginRegistrant.register(with: self) return super.application(application, didFinishLaunchingWithOptions: launchOptions) } + + func didInitializeImplicitFlutterEngine(_ engineBridge: FlutterImplicitEngineBridge) { + GeneratedPluginRegistrant.register(with: engineBridge.pluginRegistry) + } } diff --git a/packages/share_plus/share_plus/example/ios/Runner/Info.plist b/packages/share_plus/share_plus/example/ios/Runner/Info.plist index b72a8e0ab3..07e4097661 100644 --- a/packages/share_plus/share_plus/example/ios/Runner/Info.plist +++ b/packages/share_plus/share_plus/example/ios/Runner/Info.plist @@ -26,6 +26,29 @@ $(FLUTTER_BUILD_NUMBER) LSRequiresIPhoneOS + NSPhotoLibraryUsageDescription + Load photos for sharing functionality + UIApplicationSceneManifest + + UIApplicationSupportsMultipleScenes + + UISceneConfigurations + + UIWindowSceneSessionRoleApplication + + + UISceneClassName + UIWindowScene + UISceneConfigurationName + flutter + UISceneDelegateClassName + FlutterSceneDelegate + UISceneStoryboardFile + Main + + + + UIApplicationSupportsIndirectInputEvents UILaunchStoryboardName @@ -45,8 +68,6 @@ UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight - NSPhotoLibraryUsageDescription - Load photos for sharing functionality UIViewControllerBasedStatusBarAppearance diff --git a/packages/share_plus/share_plus/example/lib/main.dart b/packages/share_plus/share_plus/example/lib/main.dart index 3e4a137ba9..a7c5f1abc4 100644 --- a/packages/share_plus/share_plus/example/lib/main.dart +++ b/packages/share_plus/share_plus/example/lib/main.dart @@ -165,8 +165,9 @@ class MyHomePageState extends State { }, icon: const Icon(Icons.add), ), - if (Platform.isIOS || Platform.isMacOS) const SizedBox(height: 16), - if (Platform.isIOS || Platform.isMacOS) + if (!kIsWeb && (Platform.isIOS || Platform.isMacOS)) + const SizedBox(height: 16), + if (!kIsWeb && (Platform.isIOS || Platform.isMacOS)) ElevatedButton( onPressed: _onSelectExcludedActivityType, child: const Text('Add Excluded Activity Type'), diff --git a/packages/share_plus/share_plus/lib/src/windows_version_helper.dart b/packages/share_plus/share_plus/lib/src/windows_version_helper.dart index db0ee5aff8..41202af8f1 100644 --- a/packages/share_plus/share_plus/lib/src/windows_version_helper.dart +++ b/packages/share_plus/share_plus/lib/src/windows_version_helper.dart @@ -29,8 +29,7 @@ class VersionHelper { ..wServicePackMajor = 0 ..wServicePackMinor = 0 ..wSuiteMask = 0 - ..wProductType = 0 - ..wReserved = 0; + ..wProductType = 0; final rtlGetVersion = DynamicLibrary.open('ntdll.dll').lookupFunction< Void Function(Pointer), void Function(Pointer)>('RtlGetVersion'); diff --git a/packages/share_plus/share_plus/pubspec.yaml b/packages/share_plus/share_plus/pubspec.yaml index ceb61bdfc5..ab3ec3864e 100644 --- a/packages/share_plus/share_plus/pubspec.yaml +++ b/packages/share_plus/share_plus/pubspec.yaml @@ -28,29 +28,29 @@ flutter: pluginClass: SharePlusWindowsPluginCApi dependencies: - cross_file: ^0.3.4+2 - meta: ^1.8.0 - mime: ">=1.0.4 <3.0.0" + cross_file: ^0.3.5+2 + meta: ^1.17.0 + mime: ^2.0.0 flutter: sdk: flutter flutter_web_plugins: sdk: flutter 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 - url_launcher_linux: ^3.1.1 + file: ^7.0.1 + url_launcher_web: ^2.4.2 + url_launcher_windows: ^3.1.5 + url_launcher_linux: ^3.2.2 url_launcher_platform_interface: ^2.3.2 - ffi: ^2.1.2 - web: ^1.0.0 - win32: ">=5.5.3 <7.0.0" + ffi: ^2.2.0 + web: ^1.1.1 + win32: ^6.0.0 dev_dependencies: flutter_test: sdk: flutter - flutter_lints: ">=4.0.0 <6.0.0" + flutter_lints: ^6.0.0 environment: - sdk: ">=3.4.0 <4.0.0" - flutter: ">=3.22.0" + sdk: ">=3.11.0 <4.0.0" + flutter: ">=3.41.0" diff --git a/packages/share_plus/share_plus_platform_interface/pubspec.yaml b/packages/share_plus/share_plus_platform_interface/pubspec.yaml index 105531d888..77915fe96c 100644 --- a/packages/share_plus/share_plus_platform_interface/pubspec.yaml +++ b/packages/share_plus/share_plus_platform_interface/pubspec.yaml @@ -5,22 +5,21 @@ homepage: https://github.com/fluttercommunity/plus_plugins repository: https://github.com/fluttercommunity/plus_plugins/tree/main/packages/ dependencies: - cross_file: ^0.3.3+4 + cross_file: ^0.3.5+2 flutter: sdk: flutter - meta: ^1.8.0 - mime: ">=1.0.4 <3.0.0" - plugin_platform_interface: ^2.1.4 - path_provider: ^2.0.14 + meta: ^1.17.0 + mime: ^2.0.0 + plugin_platform_interface: ^2.1.8 + path_provider: ^2.1.5 uuid: ">=3.0.7 <5.0.0" dev_dependencies: flutter_test: sdk: flutter - mockito: ^5.4.0 - flutter_lints: ">=4.0.0 <6.0.0" - test: ^1.22.0 + mockito: ^5.6.4 + flutter_lints: ^6.0.0 environment: - sdk: ">=2.18.0 <4.0.0" - flutter: ">=3.3.0" + sdk: ">=3.11.0 <4.0.0" + flutter: ">=3.41.0" 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..67c8bff9a9 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 @@ -5,12 +5,10 @@ import 'dart:io'; import 'package:flutter/services.dart'; -import 'package:flutter_test/flutter_test.dart' - show TestDefaultBinaryMessengerBinding, TestWidgetsFlutterBinding; +import 'package:flutter_test/flutter_test.dart'; import 'package:mockito/mockito.dart'; import 'package:share_plus_platform_interface/method_channel/method_channel_share.dart'; import 'package:share_plus_platform_interface/share_plus_platform_interface.dart'; -import 'package:test/test.dart'; void main() { TestWidgetsFlutterBinding.ensureInitialized(); @@ -23,12 +21,13 @@ void main() { mockChannel = MockMethodChannel(); // Re-pipe to mockito for easier verifies. TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger - .setMockMethodCallHandler(MethodChannelShare.channel, - (MethodCall call) async { - // The explicit type can be void as the only method call has a return type of void. - await mockChannel.invokeMethod(call.method, call.arguments); - return null; - }); + .setMockMethodCallHandler(MethodChannelShare.channel, ( + MethodCall call, + ) async { + // The explicit type can be void as the only method call has a return type of void. + await mockChannel.invokeMethod(call.method, call.arguments); + return null; + }); }); test('can set SharePlatform instance', () { @@ -38,15 +37,9 @@ void main() { final newInstanceId = identityHashCode(newInstance); expect(currentId, isNot(equals(newInstanceId))); - expect( - identityHashCode(SharePlatform.instance), - equals(currentId), - ); + expect(identityHashCode(SharePlatform.instance), equals(currentId)); SharePlatform.instance = newInstance; - expect( - identityHashCode(SharePlatform.instance), - equals(newInstanceId), - ); + expect(identityHashCode(SharePlatform.instance), equals(newInstanceId)); }); test('sharing empty fails', () { @@ -69,14 +62,16 @@ void main() { excludedCupertinoActivities: [CupertinoActivityType.airDrop], ), ); - verify(mockChannel.invokeMethod('share', { - 'uri': 'https://pub.dev/packages/share_plus', - 'originX': 1.0, - 'originY': 2.0, - 'originWidth': 3.0, - 'originHeight': 4.0, - 'excludedCupertinoActivities': ['airDrop'], - })); + verify( + mockChannel.invokeMethod('share', { + 'uri': 'https://pub.dev/packages/share_plus', + 'originX': 1.0, + 'originY': 2.0, + 'originWidth': 3.0, + 'originHeight': 4.0, + 'excludedCupertinoActivities': ['airDrop'], + }), + ); await sharePlatform.share( ShareParams( @@ -86,14 +81,16 @@ void main() { excludedCupertinoActivities: [], ), ); - verify(mockChannel.invokeMethod('share', { - 'text': 'some text to share', - 'subject': 'some subject to share', - 'originX': 1.0, - 'originY': 2.0, - 'originWidth': 3.0, - 'originHeight': 4.0, - })); + verify( + mockChannel.invokeMethod('share', { + 'text': 'some text to share', + 'subject': 'some subject to share', + 'originX': 1.0, + 'originY': 2.0, + 'originWidth': 3.0, + 'originHeight': 4.0, + }), + ); await withFile('tempfile-83649a.png', (File fd) async { await sharePlatform.share( @@ -105,9 +102,8 @@ void main() { excludedCupertinoActivities: null, ), ); - verify(mockChannel.invokeMethod( - 'share', - { + verify( + mockChannel.invokeMethod('share', { 'paths': [fd.path], 'mimeTypes': ['image/png'], 'subject': 'some subject to share', @@ -116,32 +112,34 @@ void main() { 'originY': 2.0, 'originWidth': 3.0, 'originHeight': 4.0, - }, - )); + }), + ); }); }); test('sharing file sets correct mimeType', () async { await withFile('tempfile-83649b.png', (File fd) async { await sharePlatform.share(ShareParams(files: [XFile(fd.path)])); - verify(mockChannel.invokeMethod('share', { - 'paths': [fd.path], - 'mimeTypes': ['image/png'], - })); + verify( + mockChannel.invokeMethod('share', { + 'paths': [fd.path], + 'mimeTypes': ['image/png'], + }), + ); }); }); test('sharing file sets passed mimeType', () async { await withFile('tempfile-83649c.png', (File fd) async { await sharePlatform.share( - ShareParams( - files: [XFile(fd.path, mimeType: '*/*')], - ), + ShareParams(files: [XFile(fd.path, mimeType: '*/*')]), + ); + verify( + mockChannel.invokeMethod('share', { + 'paths': [fd.path], + 'mimeTypes': ['*/*'], + }), ); - verify(mockChannel.invokeMethod('share', { - 'paths': [fd.path], - 'mimeTypes': ['*/*'], - })); }); }); @@ -152,19 +150,13 @@ void main() { ); expect( - sharePlatform.share( - ShareParams(text: 'some text to share'), - ), + sharePlatform.share(ShareParams(text: 'some text to share')), completion(equals(resultUnavailable)), ); await withFile('tempfile-83649d.png', (File fd) async { expect( - sharePlatform.share( - ShareParams( - files: [XFile(fd.path)], - ), - ), + sharePlatform.share(ShareParams(files: [XFile(fd.path)])), completion(equals(resultUnavailable)), ); }); @@ -174,11 +166,12 @@ void main() { // Setup mockito to return a raw result instead of null const success = ShareResult("raw result", ShareResultStatus.success); TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger - .setMockMethodCallHandler(MethodChannelShare.channel, - (MethodCall call) async { - await mockChannel.invokeMethod(call.method, call.arguments); - return success.raw; - }); + .setMockMethodCallHandler(MethodChannelShare.channel, ( + MethodCall call, + ) async { + await mockChannel.invokeMethod(call.method, call.arguments); + return success.raw; + }); final result = await sharePlatform.share( ShareParams( @@ -187,26 +180,28 @@ void main() { sharePositionOrigin: const Rect.fromLTWH(1.0, 2.0, 3.0, 4.0), ), ); - verify(mockChannel.invokeMethod('share', { - 'text': 'some text to share', - 'subject': 'some subject to share', - 'originX': 1.0, - 'originY': 2.0, - 'originWidth': 3.0, - 'originHeight': 4.0, - })); + verify( + mockChannel.invokeMethod('share', { + 'text': 'some text to share', + 'subject': 'some subject to share', + 'originX': 1.0, + 'originY': 2.0, + 'originWidth': 3.0, + 'originHeight': 4.0, + }), + ); expect(result, success); await withFile('tempfile-83649e.png', (File fd) async { final result = await sharePlatform.share( - ShareParams( - files: [XFile(fd.path)], - ), + ShareParams(files: [XFile(fd.path)]), + ); + verify( + mockChannel.invokeMethod('share', { + 'paths': [fd.path], + 'mimeTypes': ['image/png'], + }), ); - verify(mockChannel.invokeMethod('share', { - 'paths': [fd.path], - 'mimeTypes': ['image/png'], - })); expect(result, success); }); }); @@ -227,8 +222,9 @@ Future withFile(String filename, Future Function(File fd) func) async { class MockMethodChannel extends Mock implements MethodChannel { @override Future invokeMethod(String method, [dynamic arguments]) async { - return super - .noSuchMethod(Invocation.method(#invokeMethod, [method, arguments])) + return super.noSuchMethod( + Invocation.method(#invokeMethod, [method, arguments]), + ) as dynamic; } } From 6cbdb44bb644b6dd2755b9f7ccea45413675a730 Mon Sep 17 00:00:00 2001 From: Volodymyr Date: Tue, 7 Apr 2026 18:36:51 +0300 Subject: [PATCH 3/5] chore(share_plus): Update README --- packages/share_plus/share_plus/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/share_plus/share_plus/README.md b/packages/share_plus/share_plus/README.md index ab5ca73fb1..4af5f261aa 100644 --- a/packages/share_plus/share_plus/README.md +++ b/packages/share_plus/share_plus/README.md @@ -26,7 +26,7 @@ Sharing files is not supported on Linux. ## Requirements -- Flutter >=3.41.6 +- Flutter >=3.41.0 - Dart >=3.11.0 <4.0.0 - iOS >=13.0 - macOS >=10.15 From ed53af076115217bba5c2f8fa4fbf69b2588a52c Mon Sep 17 00:00:00 2001 From: Volodymyr Date: Wed, 8 Apr 2026 11:46:59 +0300 Subject: [PATCH 4/5] chore(share_plus): Fix formatting --- .../share_plus/lib/src/share_plus_linux.dart | 6 +- .../share_plus/lib/src/share_plus_web.dart | 59 +++++-------------- .../lib/src/share_plus_windows.dart | 6 +- .../lib/src/windows_version_helper.dart | 8 ++- .../test/share_plus_linux_test.dart | 18 +++--- .../share_plus/test/share_plus_test.dart | 42 +++++++------ .../test/share_plus_windows_test.dart | 42 ++++++------- .../method_channel/method_channel_share.dart | 25 ++++---- 8 files changed, 88 insertions(+), 118 deletions(-) diff --git a/packages/share_plus/share_plus/lib/src/share_plus_linux.dart b/packages/share_plus/share_plus/lib/src/share_plus_linux.dart index 0acfd2b471..c83c626bce 100644 --- a/packages/share_plus/share_plus/lib/src/share_plus_linux.dart +++ b/packages/share_plus/share_plus/lib/src/share_plus_linux.dart @@ -32,8 +32,10 @@ class SharePlusLinuxPlugin extends SharePlatform { final uri = Uri( scheme: 'mailto', query: queryParameters.entries - .map((e) => - '${Uri.encodeComponent(e.key)}=${Uri.encodeComponent(e.value ?? '')}') + .map( + (e) => + '${Uri.encodeComponent(e.key)}=${Uri.encodeComponent(e.value ?? '')}', + ) .join('&'), ); diff --git a/packages/share_plus/share_plus/lib/src/share_plus_web.dart b/packages/share_plus/share_plus/lib/src/share_plus_web.dart index c5482a707a..8889490961 100644 --- a/packages/share_plus/share_plus/lib/src/share_plus_web.dart +++ b/packages/share_plus/share_plus/lib/src/share_plus_web.dart @@ -37,10 +37,7 @@ class SharePlusWebPlugin extends SharePlatform { try { canShare = _navigator.canShare(data); } on NoSuchMethodError catch (e) { - developer.log( - 'Share API is not supported in this User Agent.', - error: e, - ); + developer.log('Share API is not supported in this User Agent.', error: e); return _fallback(params, 'Navigator.canShare() is unavailable'); } @@ -56,10 +53,7 @@ class SharePlusWebPlugin extends SharePlatform { return _resultDismissed; } - developer.log( - 'Failed to share uri', - error: '${e.name}: ${e.message}', - ); + developer.log('Failed to share uri', error: '${e.name}: ${e.message}'); return _fallback(params, 'Navigator.share() failed: ${e.message}'); } @@ -98,38 +92,19 @@ class SharePlusWebPlugin extends SharePlatform { } if (uri != null) { - data = ShareData( - url: uri, - ); + data = ShareData(url: uri); } else if (webFiles.isNotEmpty && text != null && title != null) { - data = ShareData( - text: text, - title: title, - files: webFiles.toJS, - ); + data = ShareData(text: text, title: title, files: webFiles.toJS); } else if (webFiles.isNotEmpty && text != null) { - data = ShareData( - text: text, - files: webFiles.toJS, - ); + data = ShareData(text: text, files: webFiles.toJS); } else if (webFiles.isNotEmpty && title != null) { - data = ShareData( - title: title, - files: webFiles.toJS, - ); + data = ShareData(title: title, files: webFiles.toJS); } else if (webFiles.isNotEmpty) { - data = ShareData( - files: webFiles.toJS, - ); + data = ShareData(files: webFiles.toJS); } else if (text != null && title != null) { - data = ShareData( - text: text, - title: title, - ); + data = ShareData(text: text, title: title); } else { - data = ShareData( - text: text!, - ); + data = ShareData(text: text!); } return data; @@ -161,17 +136,16 @@ class SharePlusWebPlugin extends SharePlatform { throw Exception(error); } - final queryParameters = { - if (subject != null) 'subject': subject, - 'body': text, - }; + final queryParameters = {'subject': ?subject, 'body': text}; // see https://github.com/dart-lang/sdk/issues/43838#issuecomment-823551891 final uri = Uri( scheme: 'mailto', query: queryParameters.entries - .map((e) => - '${Uri.encodeComponent(e.key)}=${Uri.encodeComponent(e.value)}') + .map( + (e) => + '${Uri.encodeComponent(e.key)}=${Uri.encodeComponent(e.value)}', + ) .join('&'), ); @@ -227,7 +201,4 @@ class SharePlusWebPlugin extends SharePlatform { } } -const _resultDismissed = ShareResult( - '', - ShareResultStatus.dismissed, -); +const _resultDismissed = ShareResult('', ShareResultStatus.dismissed); diff --git a/packages/share_plus/share_plus/lib/src/share_plus_windows.dart b/packages/share_plus/share_plus/lib/src/share_plus_windows.dart index 5afa595fe7..4b0a834ba6 100644 --- a/packages/share_plus/share_plus/lib/src/share_plus_windows.dart +++ b/packages/share_plus/share_plus/lib/src/share_plus_windows.dart @@ -39,8 +39,10 @@ class SharePlusWindowsPlugin extends SharePlatform { final uri = Uri( scheme: 'mailto', query: queryParameters.entries - .map((e) => - '${Uri.encodeComponent(e.key)}=${Uri.encodeComponent(e.value ?? '')}') + .map( + (e) => + '${Uri.encodeComponent(e.key)}=${Uri.encodeComponent(e.value ?? '')}', + ) .join('&'), ); diff --git a/packages/share_plus/share_plus/lib/src/windows_version_helper.dart b/packages/share_plus/share_plus/lib/src/windows_version_helper.dart index 41202af8f1..de610465d2 100644 --- a/packages/share_plus/share_plus/lib/src/windows_version_helper.dart +++ b/packages/share_plus/share_plus/lib/src/windows_version_helper.dart @@ -30,9 +30,11 @@ class VersionHelper { ..wServicePackMinor = 0 ..wSuiteMask = 0 ..wProductType = 0; - final rtlGetVersion = DynamicLibrary.open('ntdll.dll').lookupFunction< - Void Function(Pointer), - void Function(Pointer)>('RtlGetVersion'); + final rtlGetVersion = DynamicLibrary.open('ntdll.dll') + .lookupFunction< + Void Function(Pointer), + void Function(Pointer) + >('RtlGetVersion'); rtlGetVersion(pointer); isWindows10RS5OrGreater = pointer.ref.dwBuildNumber >= kWindows10RS5BuildNumber; diff --git a/packages/share_plus/share_plus/test/share_plus_linux_test.dart b/packages/share_plus/share_plus/test/share_plus_linux_test.dart index 7a4c90743d..facd080132 100644 --- a/packages/share_plus/share_plus/test/share_plus_linux_test.dart +++ b/packages/share_plus/share_plus/test/share_plus_linux_test.dart @@ -13,9 +13,9 @@ void main() { test('url encoding is correct for &', () async { final mock = MockUrlLauncherPlatform(); - await SharePlusLinuxPlugin(mock).share( - ShareParams(text: 'foo&bar', subject: 'bar&foo'), - ); + await SharePlusLinuxPlugin( + mock, + ).share(ShareParams(text: 'foo&bar', subject: 'bar&foo')); expect(mock.url, 'mailto:?subject=bar%26foo&body=foo%26bar'); }); @@ -24,9 +24,9 @@ void main() { test('url encoding is correct for spaces', () async { final mock = MockUrlLauncherPlatform(); - await SharePlusLinuxPlugin(mock).share( - ShareParams(text: 'foo bar', subject: 'bar foo'), - ); + await SharePlusLinuxPlugin( + mock, + ).share(ShareParams(text: 'foo bar', subject: 'bar foo')); expect(mock.url, 'mailto:?subject=bar%20foo&body=foo%20bar'); }); @@ -34,9 +34,9 @@ void main() { test('can share URI on Linux', () async { final mock = MockUrlLauncherPlatform(); - await SharePlusLinuxPlugin(mock).share( - ShareParams(uri: Uri.parse('http://example.com')), - ); + await SharePlusLinuxPlugin( + mock, + ).share(ShareParams(uri: Uri.parse('http://example.com'))); expect(mock.url, 'mailto:?body=http%3A%2F%2Fexample.com'); }); diff --git a/packages/share_plus/share_plus/test/share_plus_test.dart b/packages/share_plus/share_plus/test/share_plus_test.dart index 3f839fab18..eb1cba6570 100644 --- a/packages/share_plus/share_plus/test/share_plus_test.dart +++ b/packages/share_plus/share_plus/test/share_plus_test.dart @@ -19,18 +19,17 @@ void main() { ); }); - test('share throws ArgumentError if both uri and text are provided', - () async { - expect( - () => sharePlus.share( - ShareParams( - uri: Uri.parse('https://example.com'), - text: 'text', + test( + 'share throws ArgumentError if both uri and text are provided', + () async { + expect( + () => sharePlus.share( + ShareParams(uri: Uri.parse('https://example.com'), text: 'text'), ), - ), - throwsA(isA()), - ); - }); + throwsA(isA()), + ); + }, + ); test('share throws ArgumentError if text is empty', () async { expect( @@ -47,14 +46,19 @@ void main() { }); test( - 'share throws ArgumentError if fileNameOverrides length does not match files length', - () async { - expect( - () => sharePlus.share(ShareParams( - files: [XFile('path')], fileNameOverrides: ['name1', 'name2'])), - throwsA(isA()), - ); - }); + 'share throws ArgumentError if fileNameOverrides length does not match files length', + () async { + expect( + () => sharePlus.share( + ShareParams( + files: [XFile('path')], + fileNameOverrides: ['name1', 'name2'], + ), + ), + throwsA(isA()), + ); + }, + ); test('share calls platform share method with correct params', () async { final params = ShareParams(text: 'text'); diff --git a/packages/share_plus/share_plus/test/share_plus_windows_test.dart b/packages/share_plus/share_plus/test/share_plus_windows_test.dart index e4038762fe..52017903bf 100644 --- a/packages/share_plus/share_plus/test/share_plus_windows_test.dart +++ b/packages/share_plus/share_plus/test/share_plus_windows_test.dart @@ -7,23 +7,15 @@ import 'package:share_plus_platform_interface/share_plus_platform_interface.dart import 'url_launcher_mock.dart'; void main() { - test( - 'registered instance', - () { - SharePlusWindowsPlugin.registerWith(); - expect(SharePlatform.instance, isA()); - }, - skip: VersionHelper.instance.isWindows10RS5OrGreater, - ); + test('registered instance', () { + SharePlusWindowsPlugin.registerWith(); + expect(SharePlatform.instance, isA()); + }, skip: VersionHelper.instance.isWindows10RS5OrGreater); - test( - 'registered instance', - () { - SharePlusWindowsPlugin.registerWith(); - expect(SharePlatform.instance, isA()); - }, - skip: !VersionHelper.instance.isWindows10RS5OrGreater, - ); + test('registered instance', () { + SharePlusWindowsPlugin.registerWith(); + expect(SharePlatform.instance, isA()); + }, skip: !VersionHelper.instance.isWindows10RS5OrGreater); // These tests are only valid on Windows versions lower than 10.0.17763.0. @@ -32,9 +24,9 @@ void main() { () async { final mock = MockUrlLauncherPlatform(); - await SharePlusWindowsPlugin(mock).share( - ShareParams(text: 'foo&bar', subject: 'bar&foo'), - ); + await SharePlusWindowsPlugin( + mock, + ).share(ShareParams(text: 'foo&bar', subject: 'bar&foo')); expect(mock.url, 'mailto:?subject=bar%26foo&body=foo%26bar'); }, @@ -47,9 +39,9 @@ void main() { () async { final mock = MockUrlLauncherPlatform(); - await SharePlusWindowsPlugin(mock).share( - ShareParams(text: 'foo bar', subject: 'bar foo'), - ); + await SharePlusWindowsPlugin( + mock, + ).share(ShareParams(text: 'foo bar', subject: 'bar foo')); expect(mock.url, 'mailto:?subject=bar%20foo&body=foo%20bar'); }, @@ -61,9 +53,9 @@ void main() { () async { final mock = MockUrlLauncherPlatform(); - await SharePlusWindowsPlugin(mock).share( - ShareParams(uri: Uri.parse('http://example.com')), - ); + await SharePlusWindowsPlugin( + mock, + ).share(ShareParams(uri: Uri.parse('http://example.com'))); expect(mock.url, 'mailto:?body=http%3A%2F%2Fexample.com'); }, 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..284752d498 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 @@ -30,10 +30,10 @@ class MethodChannelShare extends SharePlatform { Future> _toPlatformMap(ShareParams params) async { assert( - params.text != null || - params.uri != null || - (params.files != null && params.files!.isNotEmpty), - 'At least one of text, uri or files must be provided', + params.text != null || + params.uri != null || + (params.files != null && params.files!.isNotEmpty), + 'At least one of text, uri or files must be provided', ); final map = { @@ -52,7 +52,7 @@ class MethodChannelShare extends SharePlatform { if (params.files != null) { final filesWithPath = - await _getFiles(params.files!, params.fileNameOverrides); + await _getFiles(params.files!, params.fileNameOverrides); assert(filesWithPath.every((element) => element.path.isNotEmpty)); final mimeTypes = filesWithPath @@ -70,7 +70,7 @@ class MethodChannelShare extends SharePlatform { if (params.excludedCupertinoActivities != null && params.excludedCupertinoActivities!.isNotEmpty) { final excludedActivityTypes = - params.excludedCupertinoActivities!.map((e) => e.value).toList(); + params.excludedCupertinoActivities!.map((e) => e.value).toList(); map['excludedCupertinoActivities'] = excludedActivityTypes; } @@ -85,8 +85,7 @@ class MethodChannelShare extends SharePlatform { /// then make new file in TemporaryDirectory and return with path /// the system will automatically delete files in this /// TemporaryDirectory as disk space is needed elsewhere on the device - Future _getFile( - XFile file, { + Future _getFile(XFile file, { String? tempRoot, String? nameOverride, }) async { @@ -96,8 +95,8 @@ class MethodChannelShare extends SharePlatform { tempRoot ??= (await getTemporaryDirectory()).path; // Method returns null as in v2.0.0 final extension = - // ignore: dead_null_aware_expression - extensionFromMime(file.mimeType ?? 'octet-stream') ?? 'bin'; + // ignore: dead_null_aware_expression + extensionFromMime(file.mimeType ?? 'octet-stream') ?? 'bin'; //By having a UUID v4 folder wrapping the file //This path generation algorithm will not only minimize the risk of name collision but also ensure that the filename @@ -129,10 +128,8 @@ class MethodChannelShare extends SharePlatform { } /// A wrapper of [MethodChannelShare._getFile] for multiple files. - Future> _getFiles( - List files, - List? fileNameOverrides, - ) async { + Future> _getFiles(List files, + List? fileNameOverrides,) async { return Future.wait([ for (var index = 0; index < files.length; index++) _getFile( From 45accd352c3001622e96613923103b3119291a9f Mon Sep 17 00:00:00 2001 From: Volodymyr Date: Wed, 8 Apr 2026 11:58:44 +0300 Subject: [PATCH 5/5] fix format for platform interface --- .../method_channel/method_channel_share.dart | 45 +++++++++++-------- 1 file changed, 27 insertions(+), 18 deletions(-) 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 284752d498..80d6c97e51 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 @@ -16,13 +16,15 @@ import 'package:uuid/uuid.dart'; class MethodChannelShare extends SharePlatform { /// [MethodChannel] used to communicate with the platform side. @visibleForTesting - static const MethodChannel channel = - MethodChannel('dev.fluttercommunity.plus/share'); + static const MethodChannel channel = MethodChannel( + 'dev.fluttercommunity.plus/share', + ); @override Future share(ShareParams params) async { final paramsMap = await _toPlatformMap(params); - final result = await channel.invokeMethod('share', paramsMap) ?? + final result = + await channel.invokeMethod('share', paramsMap) ?? 'dev.fluttercommunity.plus/share/unavailable'; return ShareResult(result, _statusFromResult(result)); @@ -30,10 +32,10 @@ class MethodChannelShare extends SharePlatform { Future> _toPlatformMap(ShareParams params) async { assert( - params.text != null || - params.uri != null || - (params.files != null && params.files!.isNotEmpty), - 'At least one of text, uri or files must be provided', + params.text != null || + params.uri != null || + (params.files != null && params.files!.isNotEmpty), + 'At least one of text, uri or files must be provided', ); final map = { @@ -51,8 +53,10 @@ class MethodChannelShare extends SharePlatform { } if (params.files != null) { - final filesWithPath = - await _getFiles(params.files!, params.fileNameOverrides); + final filesWithPath = await _getFiles( + params.files!, + params.fileNameOverrides, + ); assert(filesWithPath.every((element) => element.path.isNotEmpty)); final mimeTypes = filesWithPath @@ -69,8 +73,9 @@ class MethodChannelShare extends SharePlatform { if (params.excludedCupertinoActivities != null && params.excludedCupertinoActivities!.isNotEmpty) { - final excludedActivityTypes = - params.excludedCupertinoActivities!.map((e) => e.value).toList(); + final excludedActivityTypes = params.excludedCupertinoActivities! + .map((e) => e.value) + .toList(); map['excludedCupertinoActivities'] = excludedActivityTypes; } @@ -85,7 +90,8 @@ class MethodChannelShare extends SharePlatform { /// then make new file in TemporaryDirectory and return with path /// the system will automatically delete files in this /// TemporaryDirectory as disk space is needed elsewhere on the device - Future _getFile(XFile file, { + Future _getFile( + XFile file, { String? tempRoot, String? nameOverride, }) async { @@ -95,8 +101,8 @@ class MethodChannelShare extends SharePlatform { tempRoot ??= (await getTemporaryDirectory()).path; // Method returns null as in v2.0.0 final extension = - // ignore: dead_null_aware_expression - extensionFromMime(file.mimeType ?? 'octet-stream') ?? 'bin'; + // ignore: dead_null_aware_expression + extensionFromMime(file.mimeType ?? 'octet-stream') ?? 'bin'; //By having a UUID v4 folder wrapping the file //This path generation algorithm will not only minimize the risk of name collision but also ensure that the filename @@ -113,7 +119,8 @@ class MethodChannelShare extends SharePlatform { //Per Issue [#3032](https://github.com/fluttercommunity/plus_plugins/issues/3032): use overridden name when available. //Per Issue [#1548](https://github.com/fluttercommunity/plus_plugins/issues/1548): attempt to use XFile.name when available - final filename = nameOverride ?? + final filename = + nameOverride ?? (filenameNotEmptyOrHasValidExt ? file.name : "${const Uuid().v1().substring(10)}.$extension"); @@ -128,14 +135,16 @@ class MethodChannelShare extends SharePlatform { } /// A wrapper of [MethodChannelShare._getFile] for multiple files. - Future> _getFiles(List files, - List? fileNameOverrides,) async { + Future> _getFiles( + List files, + List? fileNameOverrides, + ) async { return Future.wait([ for (var index = 0; index < files.length; index++) _getFile( files[index], nameOverride: fileNameOverrides?.elementAt(index), - ) + ), ]); }