From 68af39cbe71acf55ff629e0ca117957fbff4d45f Mon Sep 17 00:00:00 2001 From: FrenkyDema Date: Wed, 20 Mar 2024 17:25:47 +0100 Subject: [PATCH] Refactoring Update gradle --- .gitattributes | 2 - .metadata | 10 ++-- CHANGELOG.md | 6 +++ android/build.gradle | 4 +- android/src/main/AndroidManifest.xml | 3 +- example/.gitignore | 1 - example/android/app/build.gradle | 9 ++-- .../android/app/src/main/AndroidManifest.xml | 11 +++++ example/android/build.gradle | 13 ----- example/android/gradle.properties | 3 +- .../gradle/wrapper/gradle-wrapper.properties | 2 +- example/android/settings.gradle | 14 ++++-- .../plugin_integration_test.dart | 25 ++++++++++ example/pubspec.lock | 12 ++--- example/pubspec.yaml | 8 ++-- example/test/widget_test.dart | 4 +- pubspec.lock | 8 ++-- pubspec.yaml | 47 ++----------------- ...e_barcode_scanner_method_channel_test.dart | 13 ++--- test/qrcode_barcode_scanner_test.dart | 8 ++-- 20 files changed, 94 insertions(+), 109 deletions(-) delete mode 100644 .gitattributes create mode 100644 example/integration_test/plugin_integration_test.dart diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index dfe0770..0000000 --- a/.gitattributes +++ /dev/null @@ -1,2 +0,0 @@ -# Auto detect text files and perform LF normalization -* text=auto diff --git a/.metadata b/.metadata index f43a237..bc92567 100644 --- a/.metadata +++ b/.metadata @@ -4,7 +4,7 @@ # This file should be version controlled and should not be manually edited. version: - revision: "efbf63d9c66b9f6ec30e9ad4611189aa80003d31" + revision: "ba393198430278b6595976de84fe170f553cc728" channel: "stable" project_type: plugin @@ -13,11 +13,11 @@ project_type: plugin migration: platforms: - platform: root - create_revision: efbf63d9c66b9f6ec30e9ad4611189aa80003d31 - base_revision: efbf63d9c66b9f6ec30e9ad4611189aa80003d31 + create_revision: ba393198430278b6595976de84fe170f553cc728 + base_revision: ba393198430278b6595976de84fe170f553cc728 - platform: android - create_revision: efbf63d9c66b9f6ec30e9ad4611189aa80003d31 - base_revision: efbf63d9c66b9f6ec30e9ad4611189aa80003d31 + create_revision: ba393198430278b6595976de84fe170f553cc728 + base_revision: ba393198430278b6595976de84fe170f553cc728 # User provided section diff --git a/CHANGELOG.md b/CHANGELOG.md index 77a9946..2325385 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # CHANGELOG +## 3.0.0 + +Update gradle infrastructure +Update Scanning method +Refactoring + ## 2.0.1 dart format diff --git a/android/build.gradle b/android/build.gradle index 9241430..2c2c002 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -8,7 +8,7 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:7.3.0' + classpath 'com.android.tools.build:gradle:7.3.1' } } @@ -26,7 +26,7 @@ android { namespace 'com.example.qrcode_barcode_scanner' } - compileSdkVersion 33 + compileSdk 34 compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 diff --git a/android/src/main/AndroidManifest.xml b/android/src/main/AndroidManifest.xml index 316b470..a2f47b6 100644 --- a/android/src/main/AndroidManifest.xml +++ b/android/src/main/AndroidManifest.xml @@ -1,3 +1,2 @@ - + diff --git a/example/.gitignore b/example/.gitignore index 24476c5..29a3a50 100644 --- a/example/.gitignore +++ b/example/.gitignore @@ -27,7 +27,6 @@ migrate_working_dir/ .dart_tool/ .flutter-plugins .flutter-plugins-dependencies -.packages .pub-cache/ .pub/ /build/ diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle index 386ca01..36519a7 100644 --- a/example/android/app/build.gradle +++ b/example/android/app/build.gradle @@ -24,16 +24,15 @@ if (flutterVersionName == null) { android { namespace "com.example.qrcode_barcode_scanner_example" - compileSdkVersion flutter.compileSdkVersion - ndkVersion flutter.ndkVersion + compileSdk 34 + ndkVersion '26.2.11394342' compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 + sourceCompatibility JavaVersion.VERSION_11 + targetCompatibility JavaVersion.VERSION_11 } defaultConfig { - manifestPlaceholders = [applicationName: "android.app.Application"] // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). applicationId "com.example.qrcode_barcode_scanner_example" // You can update the following values to match your application needs. diff --git a/example/android/app/src/main/AndroidManifest.xml b/example/android/app/src/main/AndroidManifest.xml index e48c1c5..e3ee9b1 100644 --- a/example/android/app/src/main/AndroidManifest.xml +++ b/example/android/app/src/main/AndroidManifest.xml @@ -30,4 +30,15 @@ android:name="flutterEmbedding" android:value="2" /> + + + + + + + diff --git a/example/android/build.gradle b/example/android/build.gradle index 34d0a89..bc157bd 100644 --- a/example/android/build.gradle +++ b/example/android/build.gradle @@ -1,16 +1,3 @@ -buildscript { - ext.kotlin_version = '1.7.10' - repositories { - google() - mavenCentral() - } - - dependencies { - classpath 'com.android.tools.build:gradle:8.1.1' - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - } -} - allprojects { repositories { google() diff --git a/example/android/gradle.properties b/example/android/gradle.properties index b9a9a24..157da37 100644 --- a/example/android/gradle.properties +++ b/example/android/gradle.properties @@ -1,6 +1,5 @@ -org.gradle.jvmargs=-Xmx1536M +org.gradle.jvmargs=-Xmx4G android.useAndroidX=true android.enableJetifier=true -android.defaults.buildfeatures.buildconfig=true android.nonTransitiveRClass=false android.nonFinalResIds=false diff --git a/example/android/gradle/wrapper/gradle-wrapper.properties b/example/android/gradle/wrapper/gradle-wrapper.properties index 8bc9958..5e6b542 100644 --- a/example/android/gradle/wrapper/gradle-wrapper.properties +++ b/example/android/gradle/wrapper/gradle-wrapper.properties @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-all.zip diff --git a/example/android/settings.gradle b/example/android/settings.gradle index 55c4ca8..ec9974b 100644 --- a/example/android/settings.gradle +++ b/example/android/settings.gradle @@ -10,11 +10,17 @@ pluginManagement { includeBuild("${settings.ext.flutterSdkPath}/packages/flutter_tools/gradle") - plugins { - id "dev.flutter.flutter-gradle-plugin" version "1.0.0" apply false + repositories { + google() + mavenCentral() + gradlePluginPortal() } } -include ":app" +plugins { + id "dev.flutter.flutter-plugin-loader" version "1.0.0" + id "com.android.application" version '8.3.1' apply false + id "org.jetbrains.kotlin.android" version "1.7.10" apply false +} -apply from: "${settings.ext.flutterSdkPath}/packages/flutter_tools/gradle/app_plugin_loader.gradle" +include ":app" diff --git a/example/integration_test/plugin_integration_test.dart b/example/integration_test/plugin_integration_test.dart new file mode 100644 index 0000000..642729f --- /dev/null +++ b/example/integration_test/plugin_integration_test.dart @@ -0,0 +1,25 @@ +// This is a basic Flutter integration test. +// +// Since integration tests run in a full Flutter application, they can interact +// with the host side of a plugin implementation, unlike Dart unit tests. +// +// For more information about Flutter integration tests, please see +// https://docs.flutter.dev/cookbook/testing/integration/introduction + + +import 'package:flutter_test/flutter_test.dart'; +import 'package:integration_test/integration_test.dart'; + +import 'package:qrcode_barcode_scanner/qrcode_barcode_scanner.dart'; + +void main() { + IntegrationTestWidgetsFlutterBinding.ensureInitialized(); + + testWidgets('getPlatformVersion test', (WidgetTester tester) async { + final QrcodeBarcodeScanner plugin = QrcodeBarcodeScanner(onScannedCallback: (String scannedCode) { }); + final String? version = await plugin.getPlatformVersion(); + // The version string depends on the host platform running the test, so + // just assert that some non-empty string is returned. + expect(version?.isNotEmpty, true); + }); +} diff --git a/example/pubspec.lock b/example/pubspec.lock index b63e25a..fe0cb51 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -79,10 +79,10 @@ packages: dependency: "direct dev" description: name: flutter_lints - sha256: a25a15ebbdfc33ab1cd26c63a6ee519df92338a9c10f122adda92938253bef04 + sha256: e2a421b7e59244faef694ba7b30562e489c2b489866e505074eb005cd7060db7 url: "https://pub.dev" source: hosted - version: "2.0.3" + version: "3.0.1" flutter_test: dependency: "direct dev" description: flutter @@ -126,10 +126,10 @@ packages: dependency: transitive description: name: lints - sha256: "0a217c6c989d21039f1498c3ed9f3ed71b354e69873f13a8dfc3c9fe76f1b452" + sha256: cbf8d4b858bb0134ef3ef87841abdf8d63bfc255c266b7bf6b39daa1085c4290 url: "https://pub.dev" source: hosted - version: "2.1.1" + version: "3.0.0" matcher: dependency: transitive description: @@ -192,7 +192,7 @@ packages: path: ".." relative: true source: path - version: "2.0.1" + version: "3.0.0" sky_engine: dependency: transitive description: flutter @@ -279,5 +279,5 @@ packages: source: hosted version: "3.0.3" sdks: - dart: ">=3.2.0-0 <4.0.0" + dart: ">=3.3.1 <4.0.0" flutter: ">=3.3.0" diff --git a/example/pubspec.yaml b/example/pubspec.yaml index d6f62a1..0ad7df4 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -1,11 +1,11 @@ name: qrcode_barcode_scanner_example -description: Demonstrates how to use the qrcode_barcode_scanner plugin. +description: "Demonstrates how to use the qrcode_barcode_scanner plugin." # The following line prevents the package from being accidentally published to # pub.dev using `flutter pub publish`. This is preferred for private packages. publish_to: 'none' # Remove this line if you wish to publish to pub.dev environment: - sdk: '>=3.1.0 <4.0.0' + sdk: '>=3.3.1 <4.0.0' # Dependencies specify other packages that your package needs in order to work. # To automatically upgrade your package dependencies to the latest versions @@ -27,7 +27,7 @@ dependencies: # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. - cupertino_icons: ^1.0.2 + cupertino_icons: ^1.0.6 dev_dependencies: integration_test: @@ -40,7 +40,7 @@ dev_dependencies: # activated in the `analysis_options.yaml` file located at the root of your # package. See that file for information about deactivating specific lint # rules and activating additional ones. - flutter_lints: ^2.0.0 + flutter_lints: ^3.0.0 # For information on the generic Dart part of this file, see the # following page: https://dart.dev/tools/pub/pubspec diff --git a/example/test/widget_test.dart b/example/test/widget_test.dart index 4a57242..73a03ee 100644 --- a/example/test/widget_test.dart +++ b/example/test/widget_test.dart @@ -18,8 +18,8 @@ void main() { // Verify that platform version is retrieved. expect( find.byWidgetPredicate( - (Widget widget) => - widget is Text && widget.data!.startsWith('Running on:'), + (Widget widget) => widget is Text && + widget.data!.startsWith('Running on:'), ), findsOneWidget, ); diff --git a/pubspec.lock b/pubspec.lock index 3bdcb83..66ffda5 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -58,10 +58,10 @@ packages: dependency: "direct dev" description: name: flutter_lints - sha256: a25a15ebbdfc33ab1cd26c63a6ee519df92338a9c10f122adda92938253bef04 + sha256: e2a421b7e59244faef694ba7b30562e489c2b489866e505074eb005cd7060db7 url: "https://pub.dev" source: hosted - version: "2.0.3" + version: "3.0.1" flutter_test: dependency: "direct dev" description: flutter @@ -95,10 +95,10 @@ packages: dependency: transitive description: name: lints - sha256: "0a217c6c989d21039f1498c3ed9f3ed71b354e69873f13a8dfc3c9fe76f1b452" + sha256: cbf8d4b858bb0134ef3ef87841abdf8d63bfc255c266b7bf6b39daa1085c4290 url: "https://pub.dev" source: hosted - version: "2.1.1" + version: "3.0.0" matcher: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index bc5fbf0..51d89e4 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: qrcode_barcode_scanner description: Plugins to manage the reading of QR code or barcode from an external device as a keyboard. -version: 2.0.1 +version: 3.0.0 repository: "https://github.com/FrenkyDema/qrcode_barcode_scanner" environment: @@ -10,61 +10,20 @@ environment: dependencies: flutter: sdk: flutter - plugin_platform_interface: ^2.1.6 + plugin_platform_interface: ^2.1.8 dev_dependencies: flutter_test: sdk: flutter - flutter_lints: ^2.0.3 + flutter_lints: ^3.0.1 # For information on the generic Dart part of this file, see the # following page: https://dart.dev/tools/pub/pubspec # The following section is specific to Flutter packages. flutter: - # This section identifies this Flutter project as a plugin project. - # The 'pluginClass' specifies the class (in Java, Kotlin, Swift, Objective-C, etc.) - # which should be registered in the plugin registry. This is required for - # using method channels. - # The Android 'package' specifies package in which the registered class is. - # This is required for using method channels on Android. - # The 'ffiPlugin' specifies that native code should be built and bundled. - # This is required for using `dart:ffi`. - # All these are used by the tooling to maintain consistency when - # adding or updating assets for this project. plugin: platforms: android: package: com.example.qrcode_barcode_scanner pluginClass: QrcodeBarcodeScannerPlugin - - # To add assets to your plugin package, add an assets section, like this: - # assets: - # - images/a_dot_burr.jpeg - # - images/a_dot_ham.jpeg - # - # For details regarding assets in packages, see - # https://flutter.dev/assets-and-images/#from-packages - # - # An image asset can refer to one or more resolution-specific "variants", see - # https://flutter.dev/assets-and-images/#resolution-aware - - # To add custom fonts to your plugin package, add a fonts section here, - # in this "flutter" section. Each entry in this list should have a - # "family" key with the font family name, and a "fonts" key with a - # list giving the asset and other descriptors for the font. For - # example: - # fonts: - # - family: Schyler - # fonts: - # - asset: fonts/Schyler-Regular.ttf - # - asset: fonts/Schyler-Italic.ttf - # style: italic - # - family: Trajan Pro - # fonts: - # - asset: fonts/TrajanPro.ttf - # - asset: fonts/TrajanPro_Bold.ttf - # weight: 700 - # - # For details regarding fonts in packages, see - # https://flutter.dev/custom-fonts/#from-packages diff --git a/test/qrcode_barcode_scanner_method_channel_test.dart b/test/qrcode_barcode_scanner_method_channel_test.dart index 2c00718..ad2b259 100644 --- a/test/qrcode_barcode_scanner_method_channel_test.dart +++ b/test/qrcode_barcode_scanner_method_channel_test.dart @@ -3,15 +3,13 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:qrcode_barcode_scanner/qrcode_barcode_scanner_method_channel.dart'; void main() { - MethodChannelQrcodeBarcodeScanner platform = - MethodChannelQrcodeBarcodeScanner(); - const MethodChannel channel = MethodChannel('qrcode_barcode_scanner'); - TestWidgetsFlutterBinding.ensureInitialized(); + MethodChannelQrcodeBarcodeScanner platform = MethodChannelQrcodeBarcodeScanner(); + const MethodChannel channel = MethodChannel('qrcode_barcode_scanner'); + setUp(() { - TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger - .setMockMethodCallHandler( + TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler( channel, (MethodCall methodCall) async { return '42'; @@ -20,8 +18,7 @@ void main() { }); tearDown(() { - TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger - .setMockMethodCallHandler(channel, null); + TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler(channel, null); }); test('getPlatformVersion', () async { diff --git a/test/qrcode_barcode_scanner_test.dart b/test/qrcode_barcode_scanner_test.dart index 6260dac..8bef774 100644 --- a/test/qrcode_barcode_scanner_test.dart +++ b/test/qrcode_barcode_scanner_test.dart @@ -1,8 +1,8 @@ import 'package:flutter_test/flutter_test.dart'; -import 'package:plugin_platform_interface/plugin_platform_interface.dart'; import 'package:qrcode_barcode_scanner/qrcode_barcode_scanner.dart'; -import 'package:qrcode_barcode_scanner/qrcode_barcode_scanner_method_channel.dart'; import 'package:qrcode_barcode_scanner/qrcode_barcode_scanner_platform_interface.dart'; +import 'package:qrcode_barcode_scanner/qrcode_barcode_scanner_method_channel.dart'; +import 'package:plugin_platform_interface/plugin_platform_interface.dart'; class MockQrcodeBarcodeScannerPlatform with MockPlatformInterfaceMixin @@ -20,12 +20,12 @@ void main() { }); test('getPlatformVersion', () async { - QrcodeBarcodeScanner testProjectPlugin = + QrcodeBarcodeScanner qrcodeBarcodeScannerPlugin = QrcodeBarcodeScanner(onScannedCallback: (String scannedCode) {}); MockQrcodeBarcodeScannerPlatform fakePlatform = MockQrcodeBarcodeScannerPlatform(); QrcodeBarcodeScannerPlatform.instance = fakePlatform; - expect(await testProjectPlugin.getPlatformVersion(), '42'); + expect(await qrcodeBarcodeScannerPlugin.getPlatformVersion(), '42'); }); }