From 8b05dc24935c79a7b030b2d28ab9fe802c606ad2 Mon Sep 17 00:00:00 2001 From: Volodymyr Date: Thu, 8 Oct 2026 11:56:04 +0300 Subject: [PATCH 1/2] chore(android_intent_plus): Bump min Dart to 3.10.0 for platform package updates --- .../android_intent_plus/example/lib/main.dart | 78 ++--- .../android_intent_plus/example/pubspec.yaml | 4 +- .../lib/android_intent.dart | 58 ++-- packages/android_intent_plus/pubspec.yaml | 4 +- .../test/android_intent_test.dart | 295 +++++++++++------- 5 files changed, 247 insertions(+), 192 deletions(-) diff --git a/packages/android_intent_plus/example/lib/main.dart b/packages/android_intent_plus/example/lib/main.dart index ce48c1305c..d156d9d31d 100644 --- a/packages/android_intent_plus/example/lib/main.dart +++ b/packages/android_intent_plus/example/lib/main.dart @@ -27,7 +27,7 @@ class MyApp extends StatelessWidget { home: const MyHomePage(), routes: { ExplicitIntentsWidget.routeName: (BuildContext context) => - const ExplicitIntentsWidget() + const ExplicitIntentsWidget(), }, ); } @@ -58,7 +58,7 @@ class MyHomePage extends StatelessWidget { @override Widget build(BuildContext context) { Widget body; - if (const LocalPlatform().isAndroid) { + if (NativePlatform.current?.isAndroid ?? false) { body = Padding( padding: const EdgeInsets.symmetric(vertical: 15.0), child: Column( @@ -67,7 +67,8 @@ class MyHomePage extends StatelessWidget { ElevatedButton( onPressed: _createAlarm, child: const Text( - 'Tap here to set an alarm\non weekdays at 9:30pm.'), + 'Tap here to set an alarm\non weekdays at 9:30pm.', + ), ), ElevatedButton( onPressed: _parseAndLaunch, @@ -110,14 +111,13 @@ class MyHomePage extends StatelessWidget { } void _sendBroadcast() { - const intent = AndroidIntent( - action: 'com.example.broadcast', - ); + const intent = AndroidIntent(action: 'com.example.broadcast'); intent.sendBroadcast(); } void _parseAndLaunch() { - const intent = 'intent:#Intent;' + const intent = + 'intent:#Intent;' 'action=android.intent.action.SET_ALARM;' 'B.android.intent.extra.alarm.SKIP_UI=true;' 'S.android.intent.extra.alarm.MESSAGE=Create%20a%20Flutter%20app;' @@ -139,34 +139,39 @@ class ExplicitIntentsWidget extends StatelessWidget { void _openGoogleMapsStreetView() { final intent = AndroidIntent( - action: 'action_view', - data: Uri.encodeFull('google.streetview:cbll=46.414382,10.013988'), - package: 'com.google.android.apps.maps'); + action: 'action_view', + data: Uri.encodeFull('google.streetview:cbll=46.414382,10.013988'), + package: 'com.google.android.apps.maps', + ); intent.launch(); } void _displayMapInGoogleMaps({int zoomLevel = 12}) { final intent = AndroidIntent( - action: 'action_view', - data: Uri.encodeFull('geo:37.7749,-122.4194?z=$zoomLevel'), - package: 'com.google.android.apps.maps'); + action: 'action_view', + data: Uri.encodeFull('geo:37.7749,-122.4194?z=$zoomLevel'), + package: 'com.google.android.apps.maps', + ); intent.launch(); } void _launchTurnByTurnNavigationInGoogleMaps() { final intent = AndroidIntent( - action: 'action_view', - data: Uri.encodeFull( - 'google.navigation:q=Taronga+Zoo,+Sydney+Australia&avoid=tf'), - package: 'com.google.android.apps.maps'); + action: 'action_view', + data: Uri.encodeFull( + 'google.navigation:q=Taronga+Zoo,+Sydney+Australia&avoid=tf', + ), + package: 'com.google.android.apps.maps', + ); intent.launch(); } void _openLinkInGoogleChrome() { final intent = AndroidIntent( - action: 'action_view', - data: Uri.encodeFull('https://flutter.dev'), - package: 'com.android.chrome'); + action: 'action_view', + data: Uri.encodeFull('https://flutter.dev'), + package: 'com.android.chrome', + ); intent.launch(); } @@ -181,9 +186,10 @@ class ExplicitIntentsWidget extends StatelessWidget { void _testExplicitIntentFallback() { final intent = AndroidIntent( - action: 'action_view', - data: Uri.encodeFull('https://flutter.dev'), - package: 'com.android.chrome.implicit.fallback'); + action: 'action_view', + data: Uri.encodeFull('https://flutter.dev'), + package: 'com.android.chrome.implicit.fallback', + ); intent.launch(); } @@ -234,10 +240,7 @@ class ExplicitIntentsWidget extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( - appBar: AppBar( - title: const Text('Test explicit intents'), - elevation: 4, - ), + appBar: AppBar(title: const Text('Test explicit intents'), elevation: 4), body: Center( child: SingleChildScrollView( padding: const EdgeInsets.symmetric(vertical: 15.0), @@ -247,7 +250,8 @@ class ExplicitIntentsWidget extends StatelessWidget { ElevatedButton( onPressed: _openGoogleMapsStreetView, child: const Text( - 'Tap here to display panorama\nimagery in Google Street View.'), + 'Tap here to display panorama\nimagery in Google Street View.', + ), ), const SizedBox(height: 16), ElevatedButton( @@ -258,7 +262,8 @@ class ExplicitIntentsWidget extends StatelessWidget { ElevatedButton( onPressed: _launchTurnByTurnNavigationInGoogleMaps, child: const Text( - 'Tap here to launch turn-by-turn\nnavigation in Google Maps.'), + 'Tap here to launch turn-by-turn\nnavigation in Google Maps.', + ), ), const SizedBox(height: 16), ElevatedButton( @@ -274,7 +279,8 @@ class ExplicitIntentsWidget extends StatelessWidget { ElevatedButton( onPressed: _testExplicitIntentFallback, child: const Text( - 'Tap here to test explicit intent fallback to implicit.'), + 'Tap here to test explicit intent fallback to implicit.', + ), ), const SizedBox(height: 16), ElevatedButton( @@ -286,23 +292,17 @@ class ExplicitIntentsWidget extends StatelessWidget { const SizedBox(height: 16), ElevatedButton( onPressed: _openApplicationDetails, - child: const Text( - 'Tap here to open Application Details', - ), + child: const Text('Tap here to open Application Details'), ), const SizedBox(height: 16), ElevatedButton( onPressed: () => _getResolvedActivity(context), - child: const Text( - 'Tap here to get default resolved activity', - ), + child: const Text('Tap here to get default resolved activity'), ), const SizedBox(height: 16), ElevatedButton( onPressed: _openGmail, - child: const Text( - 'Tap here to open gmail app with details', - ), + child: const Text('Tap here to open gmail app with details'), ), ], ), diff --git a/packages/android_intent_plus/example/pubspec.yaml b/packages/android_intent_plus/example/pubspec.yaml index d6cdb40ee9..3e65dab127 100644 --- a/packages/android_intent_plus/example/pubspec.yaml +++ b/packages/android_intent_plus/example/pubspec.yaml @@ -2,13 +2,13 @@ name: android_intent_plus_example description: Demonstrates how to use the android_intent plugin. environment: - sdk: ">=3.1.0 <4.0.0" + sdk: ">=3.10.0 <4.0.0" flutter: ">=3.12.0" dependencies: flutter: sdk: flutter - platform: ^3.1.0 + platform: ^3.2.0 android_intent_plus: ^6.1.0 dev_dependencies: diff --git a/packages/android_intent_plus/lib/android_intent.dart b/packages/android_intent_plus/lib/android_intent.dart index d6e2fff3f1..3a737e407a 100644 --- a/packages/android_intent_plus/lib/android_intent.dart +++ b/packages/android_intent_plus/lib/android_intent.dart @@ -41,10 +41,12 @@ class AndroidIntent { this.componentName, Platform? platform, this.type, - }) : assert(action != null || componentName != null, - 'action or component (or both) must be specified'), - _channel = const MethodChannel(_kChannelName), - _platform = platform ?? const LocalPlatform(); + }) : assert( + action != null || componentName != null, + 'action or component (or both) must be specified', + ), + _channel = const MethodChannel(_kChannelName), + _platform = platform; /// This constructor is only exposed for unit testing. Do not rely on this in /// app code, it may break without warning. @@ -61,10 +63,12 @@ class AndroidIntent { this.package, this.componentName, this.type, - }) : assert(action != null || componentName != null, - 'action or component (or both) must be specified'), - _channel = channel, - _platform = platform; + }) : assert( + action != null || componentName != null, + 'action or component (or both) must be specified', + ), + _channel = channel, + _platform = platform; /// This is the general verb that the intent should attempt to do. This /// includes constants like `ACTION_VIEW`. @@ -113,7 +117,9 @@ class AndroidIntent { /// See https://developer.android.com/reference/android/content/Intent.html#setComponent(android.content.ComponentName). final String? componentName; final MethodChannel _channel; - final Platform _platform; + final Platform? _platform; + + Platform get _currentPlatform => _platform ?? Platform.current; /// Set an explicit MIME data type. /// @@ -143,7 +149,7 @@ class AndroidIntent { /// /// This works only on Android platforms. Future launch() async { - if (!_platform.isAndroid) { + if (!_currentPlatform.isAndroid) { return; } @@ -155,63 +161,55 @@ class AndroidIntent { /// Equivalent of native android Intent.parseUri(URI, Intent.URI_INTENT_SCHEME) /// This works only on Android platforms. static Future parseAndLaunch(String uri) async { - if (!const LocalPlatform().isAndroid) { + if (!(NativePlatform.current?.isAndroid ?? false)) { return; } - await const MethodChannel(_kChannelName) - .invokeMethod('parseAndLaunch', {'uri': uri}); + await const MethodChannel( + _kChannelName, + ).invokeMethod('parseAndLaunch', {'uri': uri}); } /// Launch the intent with 'createChooser(intent, title)'. /// /// This works only on Android platforms. Future launchChooser(String title) async { - if (!_platform.isAndroid) { + if (!_currentPlatform.isAndroid) { return; } final buildArguments = _buildArguments(); buildArguments['chooserTitle'] = title; - await _channel.invokeMethod( - 'launchChooser', - buildArguments, - ); + await _channel.invokeMethod('launchChooser', buildArguments); } /// Starts intent as service. /// /// This works only on Android platforms. Future sendService() async { - if (!_platform.isAndroid) { + if (!_currentPlatform.isAndroid) { return; } - await _channel.invokeMethod( - 'sendService', - _buildArguments(), - ); + await _channel.invokeMethod('sendService', _buildArguments()); } /// Sends intent as broadcast. /// /// This works only on Android platforms. Future sendBroadcast() async { - if (!_platform.isAndroid) { + if (!_currentPlatform.isAndroid) { return; } - await _channel.invokeMethod( - 'sendBroadcast', - _buildArguments(), - ); + await _channel.invokeMethod('sendBroadcast', _buildArguments()); } /// Check whether the intent can be resolved to an activity. /// /// This works only on Android platforms. Future canResolveActivity() async { - if (!_platform.isAndroid) { + if (!_currentPlatform.isAndroid) { return false; } @@ -226,7 +224,7 @@ class AndroidIntent { /// Note: ensure the calling app's AndroidManifest contains queries that match the intent. /// See: https://developer.android.com/guide/topics/manifest/queries-element Future getResolvedActivity() async { - if (!_platform.isAndroid) { + if (!_currentPlatform.isAndroid) { return null; } diff --git a/packages/android_intent_plus/pubspec.yaml b/packages/android_intent_plus/pubspec.yaml index c67b8961e8..b13e8ca8af 100644 --- a/packages/android_intent_plus/pubspec.yaml +++ b/packages/android_intent_plus/pubspec.yaml @@ -10,7 +10,7 @@ topics: - utils environment: - sdk: ">=3.1.0 <4.0.0" + sdk: ">=3.10.0 <4.0.0" flutter: ">=3.12.0" flutter: @@ -23,7 +23,7 @@ flutter: dependencies: flutter: sdk: flutter - platform: ^3.1.0 + platform: ^3.2.0 meta: ^1.8.0 dev_dependencies: diff --git a/packages/android_intent_plus/test/android_intent_test.dart b/packages/android_intent_plus/test/android_intent_test.dart index ce6fd3d4c5..ec126e1e2e 100644 --- a/packages/android_intent_plus/test/android_intent_test.dart +++ b/packages/android_intent_plus/test/android_intent_test.dart @@ -7,7 +7,7 @@ import 'package:android_intent_plus/flag.dart'; import 'package:flutter/services.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:mockito/mockito.dart'; -import 'package:platform/platform.dart'; +import 'package:platform/testing.dart'; void main() { AndroidIntent androidIntent; @@ -31,32 +31,42 @@ void main() { group('launch', () { test('pass right params', () async { androidIntent = AndroidIntent.private( - action: 'action_view', - data: Uri.encodeFull('https://flutter.dev'), - flags: [Flag.FLAG_ACTIVITY_NEW_TASK], - channel: mockChannel, - platform: FakePlatform(operatingSystem: 'android'), - type: 'video/*'); + action: 'action_view', + data: Uri.encodeFull('https://flutter.dev'), + flags: [Flag.FLAG_ACTIVITY_NEW_TASK], + channel: mockChannel, + platform: TestPlatform.fromNative( + TestNativePlatform(operatingSystem: 'android'), + ), + type: 'video/*', + ); await androidIntent.launch(); - verify(mockChannel.invokeMethod('launch', { - 'action': 'action_view', - 'data': Uri.encodeFull('https://flutter.dev'), - 'flags': - androidIntent.convertFlags([Flag.FLAG_ACTIVITY_NEW_TASK]), - 'type': 'video/*', - })); + verify( + mockChannel.invokeMethod('launch', { + 'action': 'action_view', + 'data': Uri.encodeFull('https://flutter.dev'), + 'flags': androidIntent.convertFlags([ + Flag.FLAG_ACTIVITY_NEW_TASK, + ]), + 'type': 'video/*', + }), + ); }); test('can send Intent with an action and no component', () async { androidIntent = AndroidIntent.private( action: 'action_view', channel: mockChannel, - platform: FakePlatform(operatingSystem: 'android'), + platform: TestPlatform.fromNative( + TestNativePlatform(operatingSystem: 'android'), + ), ); await androidIntent.launch(); - verify(mockChannel.invokeMethod('launch', { - 'action': 'action_view', - })); + verify( + mockChannel.invokeMethod('launch', { + 'action': 'action_view', + }), + ); }); test('can send Intent with a component and no action', () async { @@ -64,20 +74,27 @@ void main() { package: 'packageName', componentName: 'componentName', channel: mockChannel, - platform: FakePlatform(operatingSystem: 'android'), + platform: TestPlatform.fromNative( + TestNativePlatform(operatingSystem: 'android'), + ), ); await androidIntent.launch(); - verify(mockChannel.invokeMethod('launch', { - 'package': 'packageName', - 'componentName': 'componentName', - })); + verify( + mockChannel.invokeMethod('launch', { + 'package': 'packageName', + 'componentName': 'componentName', + }), + ); }); test('call in ios platform', () async { androidIntent = AndroidIntent.private( - action: 'action_view', - channel: mockChannel, - platform: FakePlatform(operatingSystem: 'ios')); + action: 'action_view', + channel: mockChannel, + platform: TestPlatform.fromNative( + TestNativePlatform(operatingSystem: 'ios'), + ), + ); await androidIntent.launch(); verifyZeroInteractions(mockChannel); }); @@ -86,34 +103,42 @@ void main() { group('canResolveActivity', () { test('pass right params', () async { androidIntent = AndroidIntent.private( - action: 'action_view', - data: Uri.encodeFull('https://flutter.dev'), - flags: [Flag.FLAG_ACTIVITY_NEW_TASK], - channel: mockChannel, - platform: FakePlatform(operatingSystem: 'android'), - type: 'video/*'); + action: 'action_view', + data: Uri.encodeFull('https://flutter.dev'), + flags: [Flag.FLAG_ACTIVITY_NEW_TASK], + channel: mockChannel, + platform: TestPlatform.fromNative( + TestNativePlatform(operatingSystem: 'android'), + ), + type: 'video/*', + ); await androidIntent.canResolveActivity(); - verify(mockChannel - .invokeMethod('canResolveActivity', { - 'action': 'action_view', - 'data': Uri.encodeFull('https://flutter.dev'), - 'flags': - androidIntent.convertFlags([Flag.FLAG_ACTIVITY_NEW_TASK]), - 'type': 'video/*', - })); + verify( + mockChannel.invokeMethod('canResolveActivity', { + 'action': 'action_view', + 'data': Uri.encodeFull('https://flutter.dev'), + 'flags': androidIntent.convertFlags([ + Flag.FLAG_ACTIVITY_NEW_TASK, + ]), + 'type': 'video/*', + }), + ); }); test('can send Intent with an action and no component', () async { androidIntent = AndroidIntent.private( action: 'action_view', channel: mockChannel, - platform: FakePlatform(operatingSystem: 'android'), + platform: TestPlatform.fromNative( + TestNativePlatform(operatingSystem: 'android'), + ), ); await androidIntent.canResolveActivity(); - verify(mockChannel - .invokeMethod('canResolveActivity', { - 'action': 'action_view', - })); + verify( + mockChannel.invokeMethod('canResolveActivity', { + 'action': 'action_view', + }), + ); }); test('can send Intent with a component and no action', () async { @@ -121,21 +146,27 @@ void main() { package: 'packageName', componentName: 'componentName', channel: mockChannel, - platform: FakePlatform(operatingSystem: 'android'), + platform: TestPlatform.fromNative( + TestNativePlatform(operatingSystem: 'android'), + ), ); await androidIntent.canResolveActivity(); - verify(mockChannel - .invokeMethod('canResolveActivity', { - 'package': 'packageName', - 'componentName': 'componentName', - })); + verify( + mockChannel.invokeMethod('canResolveActivity', { + 'package': 'packageName', + 'componentName': 'componentName', + }), + ); }); test('call in ios platform', () async { androidIntent = AndroidIntent.private( - action: 'action_view', - channel: mockChannel, - platform: FakePlatform(operatingSystem: 'ios')); + action: 'action_view', + channel: mockChannel, + platform: TestPlatform.fromNative( + TestNativePlatform(operatingSystem: 'ios'), + ), + ); await androidIntent.canResolveActivity(); verifyZeroInteractions(mockChannel); }); @@ -144,21 +175,29 @@ void main() { group('getResolvedActivity', () { test('pass right params', () async { androidIntent = AndroidIntent.private( - action: 'action_view', - data: Uri.encodeFull('https://flutter.dev'), - flags: [Flag.FLAG_ACTIVITY_NEW_TASK], - channel: mockChannel, - platform: FakePlatform(operatingSystem: 'android'), - type: 'video/*'); + action: 'action_view', + data: Uri.encodeFull('https://flutter.dev'), + flags: [Flag.FLAG_ACTIVITY_NEW_TASK], + channel: mockChannel, + platform: TestPlatform.fromNative( + TestNativePlatform(operatingSystem: 'android'), + ), + type: 'video/*', + ); await androidIntent.getResolvedActivity(); - verify(mockChannel - .invokeMethod('getResolvedActivity', { - 'action': 'action_view', - 'data': Uri.encodeFull('https://flutter.dev'), - 'flags': - androidIntent.convertFlags([Flag.FLAG_ACTIVITY_NEW_TASK]), - 'type': 'video/*', - })); + verify( + mockChannel.invokeMethod( + 'getResolvedActivity', + { + 'action': 'action_view', + 'data': Uri.encodeFull('https://flutter.dev'), + 'flags': androidIntent.convertFlags([ + Flag.FLAG_ACTIVITY_NEW_TASK, + ]), + 'type': 'video/*', + }, + ), + ); }); test('returns a ResolvedActivity', () async { @@ -166,15 +205,18 @@ void main() { action: 'action_view', data: Uri.encodeFull('https://flutter.dev'), channel: mockChannel, - platform: FakePlatform(operatingSystem: 'android'), + platform: TestPlatform.fromNative( + TestNativePlatform(operatingSystem: 'android'), + ), ); - when(mockChannel.invokeMethod("getResolvedActivity", any)) - .thenAnswer((_) async => { - "activityName": "activity name", - "appName": "App Name", - "packageName": "com.packagename", - }); + when(mockChannel.invokeMethod("getResolvedActivity", any)).thenAnswer( + (_) async => { + "activityName": "activity name", + "appName": "App Name", + "packageName": "com.packagename", + }, + ); final result = await androidIntent.getResolvedActivity(); @@ -187,13 +229,17 @@ void main() { androidIntent = AndroidIntent.private( action: 'action_view', channel: mockChannel, - platform: FakePlatform(operatingSystem: 'android'), + platform: TestPlatform.fromNative( + TestNativePlatform(operatingSystem: 'android'), + ), ); await androidIntent.getResolvedActivity(); - verify(mockChannel - .invokeMethod('getResolvedActivity', { - 'action': 'action_view', - })); + verify( + mockChannel.invokeMethod( + 'getResolvedActivity', + {'action': 'action_view'}, + ), + ); }); test('can send Intent with a component and no action', () async { @@ -201,21 +247,30 @@ void main() { package: 'packageName', componentName: 'componentName', channel: mockChannel, - platform: FakePlatform(operatingSystem: 'android'), + platform: TestPlatform.fromNative( + TestNativePlatform(operatingSystem: 'android'), + ), ); await androidIntent.getResolvedActivity(); - verify(mockChannel - .invokeMethod('getResolvedActivity', { - 'package': 'packageName', - 'componentName': 'componentName', - })); + verify( + mockChannel.invokeMethod( + 'getResolvedActivity', + { + 'package': 'packageName', + 'componentName': 'componentName', + }, + ), + ); }); test('call in ios platform', () async { androidIntent = AndroidIntent.private( - action: 'action_view', - channel: mockChannel, - platform: FakePlatform(operatingSystem: 'ios')); + action: 'action_view', + channel: mockChannel, + platform: TestPlatform.fromNative( + TestNativePlatform(operatingSystem: 'ios'), + ), + ); await androidIntent.getResolvedActivity(); verifyZeroInteractions(mockChannel); }); @@ -226,13 +281,17 @@ void main() { androidIntent = AndroidIntent.private( action: 'action_view', channel: mockChannel, - platform: FakePlatform(operatingSystem: 'android'), + platform: TestPlatform.fromNative( + TestNativePlatform(operatingSystem: 'android'), + ), ); await androidIntent.launchChooser('title'); - verify(mockChannel.invokeMethod('launchChooser', { - 'action': 'action_view', - 'chooserTitle': 'title', - })); + verify( + mockChannel.invokeMethod('launchChooser', { + 'action': 'action_view', + 'chooserTitle': 'title', + }), + ); }); }); @@ -241,12 +300,16 @@ void main() { androidIntent = AndroidIntent.private( action: 'com.example.service', channel: mockChannel, - platform: FakePlatform(operatingSystem: 'android'), + platform: TestPlatform.fromNative( + TestNativePlatform(operatingSystem: 'android'), + ), ); await androidIntent.sendService(); - verify(mockChannel.invokeMethod('sendService', { - 'action': 'com.example.service', - })); + verify( + mockChannel.invokeMethod('sendService', { + 'action': 'com.example.service', + }), + ); }); }); @@ -255,44 +318,37 @@ void main() { androidIntent = AndroidIntent.private( action: 'com.example.broadcast', channel: mockChannel, - platform: FakePlatform(operatingSystem: 'android'), + platform: TestPlatform.fromNative( + TestNativePlatform(operatingSystem: 'android'), + ), ); await androidIntent.sendBroadcast(); - verify(mockChannel.invokeMethod('sendBroadcast', { - 'action': 'com.example.broadcast', - })); + verify( + mockChannel.invokeMethod('sendBroadcast', { + 'action': 'com.example.broadcast', + }), + ); }); }); }); group('convertFlags ', () { - androidIntent = const AndroidIntent( - action: 'action_view', - ); + androidIntent = const AndroidIntent(action: 'action_view'); test('add filled flag list', () async { final flags = []; flags.add(Flag.FLAG_ACTIVITY_NEW_TASK); flags.add(Flag.FLAG_ACTIVITY_NEW_DOCUMENT); - expect( - androidIntent.convertFlags(flags), - 268959744, - ); + expect(androidIntent.convertFlags(flags), 268959744); }); test('add flags whose values are not power of 2', () async { final flags = []; flags.add(100); flags.add(10); - expect( - () => androidIntent.convertFlags(flags), - throwsArgumentError, - ); + expect(() => androidIntent.convertFlags(flags), throwsArgumentError); }); test('add empty flag list', () async { final flags = []; - expect( - androidIntent.convertFlags(flags), - 0, - ); + expect(androidIntent.convertFlags(flags), 0); }); }); } @@ -301,8 +357,9 @@ void main() { 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 c08b810450c1240438d98bd6eb30f44903f9a862 Mon Sep 17 00:00:00 2001 From: Volodymyr Date: Thu, 8 Oct 2026 12:14:57 +0300 Subject: [PATCH 2/2] chore(android_intent_plus): Format tests with latest Dart --- .../android_intent_plus_test.dart | 98 ++++++++++--------- 1 file changed, 54 insertions(+), 44 deletions(-) diff --git a/packages/android_intent_plus/example/integration_test/android_intent_plus_test.dart b/packages/android_intent_plus/example/integration_test/android_intent_plus_test.dart index 341cac544a..235edfa0b1 100644 --- a/packages/android_intent_plus/example/integration_test/android_intent_plus_test.dart +++ b/packages/android_intent_plus/example/integration_test/android_intent_plus_test.dart @@ -39,33 +39,40 @@ void main() { } }); - testWidgets('Launch throws when no Activity is found', - (WidgetTester tester) async { + testWidgets('Launch throws when no Activity is found', ( + WidgetTester tester, + ) async { // We can't test that any of this is really working, this is mostly just // checking that the plugin API is registered. Only works on Android. const intent = AndroidIntent(action: 'LAUNCH', package: 'foobar'); - await expectLater(() async => await intent.launch(), throwsA((Exception e) { - return e is PlatformException && - e.message!.contains('No Activity found to handle Intent'); - })); + await expectLater( + () async => await intent.launch(), + throwsA((Exception e) { + return e is PlatformException && + e.message!.contains('No Activity found to handle Intent'); + }), + ); }, skip: !Platform.isAndroid); - testWidgets('Set an alarm on weekdays at 9:30pm should not throw', - (WidgetTester tester) async { + testWidgets('Set an alarm on weekdays at 9:30pm should not throw', ( + WidgetTester tester, + ) async { const intent = AndroidIntent( - action: 'android.intent.action.SET_ALARM', - arguments: { - 'android.intent.extra.alarm.DAYS': [2, 3, 4, 5, 6], - 'android.intent.extra.alarm.HOUR': 21, - 'android.intent.extra.alarm.MINUTES': 30, - 'android.intent.extra.alarm.SKIP_UI': true, - 'android.intent.extra.alarm.MESSAGE': 'Just for Integration test', - }); + action: 'android.intent.action.SET_ALARM', + arguments: { + 'android.intent.extra.alarm.DAYS': [2, 3, 4, 5, 6], + 'android.intent.extra.alarm.HOUR': 21, + 'android.intent.extra.alarm.MINUTES': 30, + 'android.intent.extra.alarm.SKIP_UI': true, + 'android.intent.extra.alarm.MESSAGE': 'Just for Integration test', + }, + ); await intent.launch(); }, skip: !Platform.isAndroid); testWidgets('Parse and Launch should not throw', (WidgetTester tester) async { - const intent = 'intent:#Intent;' + const intent = + 'intent:#Intent;' 'action=android.intent.action.SET_ALARM;' 'B.android.intent.extra.alarm.SKIP_UI=true;' 'S.android.intent.extra.alarm.MESSAGE=Create%20a%20Flutter%20app;' @@ -86,47 +93,50 @@ void main() { }, skip: !Platform.isAndroid); testWidgets('sendService should not throw', (WidgetTester tester) async { - const intent = AndroidIntent( - action: 'com.example.service', - ); + const intent = AndroidIntent(action: 'com.example.service'); await intent.sendService(); }, skip: !Platform.isAndroid); testWidgets('SendBroadcast should not throw', (WidgetTester tester) async { - const intent = AndroidIntent( - action: 'com.example.broadcast', - ); + const intent = AndroidIntent(action: 'com.example.broadcast'); await intent.sendBroadcast(); }, skip: !Platform.isAndroid); - testWidgets('CanResolveActivity returns true when example Activity is found', - (WidgetTester tester) async { - const intent = AndroidIntent( - action: 'action_view', - package: 'io.flutter.plugins.androidintentexample', - componentName: 'io.flutter.plugins.androidintentexample.MainActivity', - ); - await expectLater(await intent.canResolveActivity(), isTrue); - }, skip: !Platform.isAndroid); + testWidgets( + 'CanResolveActivity returns true when example Activity is found', + (WidgetTester tester) async { + const intent = AndroidIntent( + action: 'action_view', + package: 'io.flutter.plugins.androidintentexample', + componentName: 'io.flutter.plugins.androidintentexample.MainActivity', + ); + await expectLater(await intent.canResolveActivity(), isTrue); + }, + skip: !Platform.isAndroid, + ); - testWidgets('CanResolveActivity returns false when no Activity is found', - (WidgetTester tester) async { + testWidgets('CanResolveActivity returns false when no Activity is found', ( + WidgetTester tester, + ) async { const intent = AndroidIntent(action: 'LAUNCH', package: 'foobar'); await expectLater(await intent.canResolveActivity(), isFalse); }, skip: !Platform.isAndroid); testWidgets( - 'getResolvedActivity return activity details when example Activity is found', - (WidgetTester tester) async { - final intent = AndroidIntent( - action: 'action_view', - data: Uri.encodeFull('http://'), - ); - await expectLater(await intent.getResolvedActivity(), isNotNull); - }, skip: !Platform.isAndroid); + 'getResolvedActivity return activity details when example Activity is found', + (WidgetTester tester) async { + final intent = AndroidIntent( + action: 'action_view', + data: Uri.encodeFull('http://'), + ); + await expectLater(await intent.getResolvedActivity(), isNotNull); + }, + skip: !Platform.isAndroid, + ); - testWidgets('getResolvedActivity returns null when no Activity is found', - (WidgetTester tester) async { + testWidgets('getResolvedActivity returns null when no Activity is found', ( + WidgetTester tester, + ) async { final intent = AndroidIntent( action: 'action_view', data: Uri.encodeFull('mycustomscheme://'),