From abeecb58c8e136d059815728bce728c5c1fb6d27 Mon Sep 17 00:00:00 2001 From: Piotr Mitkowski Date: Mon, 21 Aug 2023 11:53:32 +0200 Subject: [PATCH] Flutter 3.10, Dart 3, Gradle 8 and Xcode 14.3 support (#11) * Updated Flutter version and dependencies * Updated Flutter version and dependencies * Refactored Dart view implementation to use switch expression * Updated Android project to use the latest Gradle version (8.0) * Updated docs * Updated Flutter version used in CI * Updated dependencies --- .fvm/fvm_config.json | 2 +- .github/workflows/test.yml | 2 +- CHANGELOG.md | 3 + README.md | 6 +- android/build.gradle | 3 +- .../android/app/src/main/AndroidManifest.xml | 3 +- example/android/build.gradle | 4 +- example/android/gradle.properties | 3 + .../gradle/wrapper/gradle-wrapper.properties | 2 +- example/ios/Podfile.lock | 4 +- example/pubspec.lock | 154 +++++++++--------- example/pubspec.yaml | 4 +- .../ARQuidoViewController.swift | 2 +- ios/ar_quido.podspec | 2 +- lib/src/ar_quido_method_channel.dart | 61 ++++--- pubspec.yaml | 16 +- test/ar_quido_method_channel_test.dart | 4 +- 17 files changed, 142 insertions(+), 133 deletions(-) diff --git a/.fvm/fvm_config.json b/.fvm/fvm_config.json index 69fe147..2f49d15 100644 --- a/.fvm/fvm_config.json +++ b/.fvm/fvm_config.json @@ -1,4 +1,4 @@ { - "flutterSdkVersion": "3.7.7", + "flutterSdkVersion": "3.10.6", "flavors": {} } \ No newline at end of file diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5deb5d6..ae6aee6 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -19,7 +19,7 @@ jobs: - name: Install and set Flutter version uses: subosito/flutter-action@v2.4.0 with: - flutter-version: '3.7.7' + flutter-version: '3.10.6' - name: Restore packages run: flutter pub get - name: Generate required files diff --git a/CHANGELOG.md b/CHANGELOG.md index 89dc05a..fb34252 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## 0.1.5 +* Updated the project to match Flutter 3.10.6, Dart 3, Gradle 8 and Xcode 14.3 + ## 0.1.4 * Improved performance to fix a bug causing an OutOfMemoryError on some Android devices diff --git a/README.md b/README.md index f6e61e1..b4f1377 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ Add the dependency in your `pubspec.yaml`: - directly in pubspec.yaml: ```yaml dependencies: - ar_quido: 0.1.4 + ar_quido: 0.1.5 ``` ### Android Since the Android version depends on the EasyAR solution, you need to @@ -41,10 +41,10 @@ in Info.plist: Describe why your app needs camera (AR) here. ``` -Also make sure, that your deployment target in project settings is set to 13.0. +Also make sure, that your deployment target in project settings is set to at least 14.0. Set the same version in `ios/Podfile`: ```ruby -platform :ios, '13.0' +platform :ios, '14.0' ``` ## Usage 🌴 diff --git a/android/build.gradle b/android/build.gradle index c4dab9f..de8e66f 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -9,7 +9,7 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:7.2.0' + classpath 'com.android.tools.build:gradle:7.2.2' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } @@ -25,6 +25,7 @@ apply plugin: 'com.android.library' apply plugin: 'kotlin-android' android { + namespace 'com.miquido.ar_quido' compileSdkVersion 33 compileOptions { diff --git a/example/android/app/src/main/AndroidManifest.xml b/example/android/app/src/main/AndroidManifest.xml index de14c82..eed477a 100644 --- a/example/android/app/src/main/AndroidManifest.xml +++ b/example/android/app/src/main/AndroidManifest.xml @@ -1,5 +1,4 @@ - + =2.19.1 <3.0.0" - flutter: ">=3.3.10" + dart: ">=3.0.0 <4.0.0" + flutter: ">=3.10.6" diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 754a5a6..7f33a5b 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -11,12 +11,12 @@ dependencies: cupertino_icons: 1.0.5 flutter: sdk: flutter - permission_handler: 10.2.0 + permission_handler: 10.4.3 dev_dependencies: flutter_test: sdk: flutter - lint_quido: 0.4.0 + lint_quido: 1.10.0 flutter: diff --git a/ios/Classes/ARImageScannerView/ARQuidoViewController.swift b/ios/Classes/ARImageScannerView/ARQuidoViewController.swift index 0610de1..32843c3 100644 --- a/ios/Classes/ARImageScannerView/ARQuidoViewController.swift +++ b/ios/Classes/ARImageScannerView/ARQuidoViewController.swift @@ -242,7 +242,7 @@ extension ARQuidoViewController: ImageRecognitionDelegate { } func onRecognitionStarted() { - methodChannel.invokeMethod("scanner#start", arguments: [:]) + methodChannel.invokeMethod("scanner#start", arguments: [String:Any]()) } func onDetect(imageKey: String) { diff --git a/ios/ar_quido.podspec b/ios/ar_quido.podspec index 31af4e1..2b24d97 100644 --- a/ios/ar_quido.podspec +++ b/ios/ar_quido.podspec @@ -17,7 +17,7 @@ Downloaded by pub (not CocoaPods) s.documentation_url = 'https://pub.dev/packages/ar_quido' s.source_files = 'Classes/**/*' s.dependency 'Flutter' - s.platform = :ios, '13.0' + s.platform = :ios, '14.0' # Flutter.framework does not contain a i386 slice. s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386' } diff --git a/lib/src/ar_quido_method_channel.dart b/lib/src/ar_quido_method_channel.dart index 291eecd..0c4eac0 100644 --- a/lib/src/ar_quido_method_channel.dart +++ b/lib/src/ar_quido_method_channel.dart @@ -71,34 +71,35 @@ class ARQuidoMethodChannel extends ARQuidoPlatform { required List referenceImageNames, }) { final creationParams = _buildCreationParams(referenceImageNames); - if (defaultTargetPlatform == TargetPlatform.android) { - return PlatformViewLink( - viewType: ARQuidoMethodChannel._androidViewType, - surfaceFactory: (context, controller) { - return AndroidViewSurface( - controller: controller as AndroidViewController, - hitTestBehavior: PlatformViewHitTestBehavior.opaque, - gestureRecognizers: const >{}, - ); - }, - onCreatePlatformView: (params) => _onCreatePlatformView( - params, - creationParams, - onPlatformViewCreated, + return switch (defaultTargetPlatform) { + TargetPlatform.android => PlatformViewLink( + viewType: ARQuidoMethodChannel._androidViewType, + surfaceFactory: (context, controller) { + return AndroidViewSurface( + controller: controller as AndroidViewController, + hitTestBehavior: PlatformViewHitTestBehavior.opaque, + gestureRecognizers: const >{}, + ); + }, + onCreatePlatformView: (params) => _onCreatePlatformView( + params, + creationParams, + onPlatformViewCreated, + ), ), - ); - } else if (defaultTargetPlatform == TargetPlatform.iOS) { - return UiKitView( - viewType: ARQuidoMethodChannel._iOSViewType, - layoutDirection: TextDirection.ltr, - creationParams: creationParams, - creationParamsCodec: const StandardMessageCodec(), - gestureRecognizers: const >{}, - onPlatformViewCreated: onPlatformViewCreated, - ); - } else { - throw Exception('$defaultTargetPlatform is not supported by ARQuidoView'); - } + TargetPlatform.iOS => UiKitView( + viewType: ARQuidoMethodChannel._iOSViewType, + layoutDirection: TextDirection.ltr, + creationParams: creationParams, + creationParamsCodec: const StandardMessageCodec(), + gestureRecognizers: const >{}, + onPlatformViewCreated: onPlatformViewCreated, + ), + _ => throw Exception( + '$defaultTargetPlatform is not supported by ARQuidoView', + ), + }; } AndroidViewController _onCreatePlatformView( @@ -128,28 +129,22 @@ class ARQuidoMethodChannel extends ARQuidoPlatform { switch (call.method) { case 'scanner#start': _scannerEventStreamController.add(RecognitionStartedEvent()); - break; case 'scanner#recognitionPaused': _scannerEventStreamController.add(RecognitionPausedEvent()); - break; case 'scanner#recognitionResumed': _scannerEventStreamController.add(RecognitionResumedEvent()); - break; case 'scanner#onImageDetected': final arguments = (call.arguments as Map).cast(); final imageName = arguments['imageName']; _scannerEventStreamController.add(ImageDetectedEvent(imageName)); - break; case 'scanner#onDetectedImageTapped': final arguments = (call.arguments as Map).cast(); final imageName = arguments['imageName']; _scannerEventStreamController.add(ImageTappedEvent(imageName)); - break; case 'scanner#error': final arguments = (call.arguments as Map).cast(); final error = arguments['errorCode']; _scannerEventStreamController.add(ErrorEvent(error!)); - break; default: throw MissingPluginException(); } diff --git a/pubspec.yaml b/pubspec.yaml index 76f3610..062e65b 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,28 +1,28 @@ name: ar_quido description: A Flutter plugin for handling image recognition on mobile platforms -version: 0.1.4 +version: 0.1.5 repository: https://github.com/miquido/ar_quido issue_tracker: https://github.com/miquido/ar_quido/issues homepage: https://github.com/miquido/ar_quido documentation: https://pub.dev/documentation/ar_quido/latest/ environment: - sdk: '>=2.19.1 <3.0.0' - flutter: ">=3.3.10" + sdk: '>=3.0.0 <4.0.0' + flutter: ">=3.10.6" dependencies: flutter: sdk: flutter - plugin_platform_interface: ^2.1.4 + plugin_platform_interface: ^2.1.4 stream_transform: ^2.1.0 dev_dependencies: - async: 2.10.0 - build_runner: 2.3.3 + async: 2.11.0 + build_runner: 2.4.6 flutter_test: sdk: flutter - lint_quido: 0.4.0 - mockito: 5.3.2 + lint_quido: 1.10.0 + mockito: 5.4.2 flutter: diff --git a/test/ar_quido_method_channel_test.dart b/test/ar_quido_method_channel_test.dart index 9641621..670e96a 100644 --- a/test/ar_quido_method_channel_test.dart +++ b/test/ar_quido_method_channel_test.dart @@ -12,7 +12,7 @@ void main() { setUpAll(platform.init); setUp(() { - TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger + TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger .setMockMethodCallHandler( platform.methodChannel, (message) async { @@ -139,7 +139,7 @@ Future _sendPlatformMessage( ) async { final byteData = const StandardMethodCodec().encodeMethodCall(MethodCall(method, data)); - await TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger + await TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger .handlePlatformMessage( 'plugins.miquido.com/ar_quido', byteData,