From cf212de322828d8845a790084f54c40ae55daa2d Mon Sep 17 00:00:00 2001 From: Adam Velebil Date: Fri, 22 Apr 2022 11:22:59 +0200 Subject: [PATCH] new plugin replacing mobile_scanner --- .../qrscanner_mlkit/.gitignore | 30 ++ .../flutter_plugins/qrscanner_mlkit/.metadata | 30 ++ .../qrscanner_mlkit/CHANGELOG.md | 3 + .../flutter_plugins/qrscanner_mlkit/LICENSE | 0 .../flutter_plugins/qrscanner_mlkit/README.md | 4 + .../qrscanner_mlkit/analysis_options.yaml | 4 + .../qrscanner_mlkit/android/.gitignore | 9 + .../qrscanner_mlkit/android/build.gradle | 61 +++++ .../qrscanner_mlkit/android/gradle.properties | 15 + .../gradle/wrapper/gradle-wrapper.properties | 6 + .../qrscanner_mlkit/android/settings.gradle | 1 + .../android/src/main/AndroidManifest.xml | 8 + .../qrscanner_mlkit/QRScannerMLKitPlugin.kt | 85 ++++++ .../qrscanner_mlkit/QRScannerView.kt | 257 ++++++++++++++++++ .../src/main/res/layout/qr_scanner_view.xml | 20 ++ .../android/src/main/res/values/strings.xml | 5 + .../qrscanner_mlkit/example/.gitignore | 47 ++++ .../qrscanner_mlkit/example/README.md | 16 ++ .../example/analysis_options.yaml | 29 ++ .../example/android/.gitignore | 13 + .../example/android/app/build.gradle | 71 +++++ .../android/app/src/debug/AndroidManifest.xml | 8 + .../android/app/src/main/AndroidManifest.xml | 34 +++ .../qrscanner_mlkit_example/MainActivity.kt | 6 + .../res/drawable-v21/launch_background.xml | 12 + .../main/res/drawable/launch_background.xml | 12 + .../src/main/res/mipmap-hdpi/ic_launcher.png | Bin 0 -> 544 bytes .../src/main/res/mipmap-mdpi/ic_launcher.png | Bin 0 -> 442 bytes .../src/main/res/mipmap-xhdpi/ic_launcher.png | Bin 0 -> 721 bytes .../main/res/mipmap-xxhdpi/ic_launcher.png | Bin 0 -> 1031 bytes .../main/res/mipmap-xxxhdpi/ic_launcher.png | Bin 0 -> 1443 bytes .../app/src/main/res/values-night/styles.xml | 18 ++ .../app/src/main/res/values/styles.xml | 18 ++ .../app/src/profile/AndroidManifest.xml | 8 + .../example/android/build.gradle | 31 +++ .../example/android/gradle.properties | 3 + .../gradle/wrapper/gradle-wrapper.properties | 6 + .../example/android/settings.gradle | 11 + .../qrscanner_mlkit/example/lib/main.dart | 62 +++++ .../qrscanner_mlkit/example/pubspec.lock | 182 +++++++++++++ .../qrscanner_mlkit/example/pubspec.yaml | 24 ++ .../example/test/widget_test.dart | 27 ++ .../qrscanner_mlkit/lib/qrscanner_mlkit.dart | 7 + .../lib/qrscanner_mlkit_method_channel.dart | 17 ++ .../qrscanner_mlkit_platform_interface.dart | 29 ++ .../lib/qrscanner_mlkit_view.dart | 70 +++++ .../qrscanner_mlkit/pubspec.yaml | 25 ++ .../qrscanner_mlkit_method_channel_test.dart | 24 ++ .../test/qrscanner_mlkit_test.dart | 26 ++ lib/android/qr_scanner/qr_scanner_view.dart | 27 +- pubspec.lock | 18 +- pubspec.yaml | 6 +- 52 files changed, 1393 insertions(+), 32 deletions(-) create mode 100644 android/flutter_plugins/qrscanner_mlkit/.gitignore create mode 100644 android/flutter_plugins/qrscanner_mlkit/.metadata create mode 100644 android/flutter_plugins/qrscanner_mlkit/CHANGELOG.md create mode 100644 android/flutter_plugins/qrscanner_mlkit/LICENSE create mode 100644 android/flutter_plugins/qrscanner_mlkit/README.md create mode 100644 android/flutter_plugins/qrscanner_mlkit/analysis_options.yaml create mode 100644 android/flutter_plugins/qrscanner_mlkit/android/.gitignore create mode 100644 android/flutter_plugins/qrscanner_mlkit/android/build.gradle create mode 100644 android/flutter_plugins/qrscanner_mlkit/android/gradle.properties create mode 100644 android/flutter_plugins/qrscanner_mlkit/android/gradle/wrapper/gradle-wrapper.properties create mode 100644 android/flutter_plugins/qrscanner_mlkit/android/settings.gradle create mode 100644 android/flutter_plugins/qrscanner_mlkit/android/src/main/AndroidManifest.xml create mode 100644 android/flutter_plugins/qrscanner_mlkit/android/src/main/kotlin/com/yubico/authenticator/flutter_plugins/qrscanner_mlkit/QRScannerMLKitPlugin.kt create mode 100644 android/flutter_plugins/qrscanner_mlkit/android/src/main/kotlin/com/yubico/authenticator/flutter_plugins/qrscanner_mlkit/QRScannerView.kt create mode 100644 android/flutter_plugins/qrscanner_mlkit/android/src/main/res/layout/qr_scanner_view.xml create mode 100644 android/flutter_plugins/qrscanner_mlkit/android/src/main/res/values/strings.xml create mode 100644 android/flutter_plugins/qrscanner_mlkit/example/.gitignore create mode 100644 android/flutter_plugins/qrscanner_mlkit/example/README.md create mode 100644 android/flutter_plugins/qrscanner_mlkit/example/analysis_options.yaml create mode 100644 android/flutter_plugins/qrscanner_mlkit/example/android/.gitignore create mode 100644 android/flutter_plugins/qrscanner_mlkit/example/android/app/build.gradle create mode 100644 android/flutter_plugins/qrscanner_mlkit/example/android/app/src/debug/AndroidManifest.xml create mode 100644 android/flutter_plugins/qrscanner_mlkit/example/android/app/src/main/AndroidManifest.xml create mode 100644 android/flutter_plugins/qrscanner_mlkit/example/android/app/src/main/kotlin/com/yubico/authenticator/flutter_plugins/qrscanner_mlkit_example/MainActivity.kt create mode 100644 android/flutter_plugins/qrscanner_mlkit/example/android/app/src/main/res/drawable-v21/launch_background.xml create mode 100644 android/flutter_plugins/qrscanner_mlkit/example/android/app/src/main/res/drawable/launch_background.xml create mode 100644 android/flutter_plugins/qrscanner_mlkit/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png create mode 100644 android/flutter_plugins/qrscanner_mlkit/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png create mode 100644 android/flutter_plugins/qrscanner_mlkit/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png create mode 100644 android/flutter_plugins/qrscanner_mlkit/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png create mode 100644 android/flutter_plugins/qrscanner_mlkit/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png create mode 100644 android/flutter_plugins/qrscanner_mlkit/example/android/app/src/main/res/values-night/styles.xml create mode 100644 android/flutter_plugins/qrscanner_mlkit/example/android/app/src/main/res/values/styles.xml create mode 100644 android/flutter_plugins/qrscanner_mlkit/example/android/app/src/profile/AndroidManifest.xml create mode 100644 android/flutter_plugins/qrscanner_mlkit/example/android/build.gradle create mode 100644 android/flutter_plugins/qrscanner_mlkit/example/android/gradle.properties create mode 100644 android/flutter_plugins/qrscanner_mlkit/example/android/gradle/wrapper/gradle-wrapper.properties create mode 100644 android/flutter_plugins/qrscanner_mlkit/example/android/settings.gradle create mode 100644 android/flutter_plugins/qrscanner_mlkit/example/lib/main.dart create mode 100644 android/flutter_plugins/qrscanner_mlkit/example/pubspec.lock create mode 100644 android/flutter_plugins/qrscanner_mlkit/example/pubspec.yaml create mode 100644 android/flutter_plugins/qrscanner_mlkit/example/test/widget_test.dart create mode 100644 android/flutter_plugins/qrscanner_mlkit/lib/qrscanner_mlkit.dart create mode 100644 android/flutter_plugins/qrscanner_mlkit/lib/qrscanner_mlkit_method_channel.dart create mode 100644 android/flutter_plugins/qrscanner_mlkit/lib/qrscanner_mlkit_platform_interface.dart create mode 100644 android/flutter_plugins/qrscanner_mlkit/lib/qrscanner_mlkit_view.dart create mode 100644 android/flutter_plugins/qrscanner_mlkit/pubspec.yaml create mode 100644 android/flutter_plugins/qrscanner_mlkit/test/qrscanner_mlkit_method_channel_test.dart create mode 100644 android/flutter_plugins/qrscanner_mlkit/test/qrscanner_mlkit_test.dart diff --git a/android/flutter_plugins/qrscanner_mlkit/.gitignore b/android/flutter_plugins/qrscanner_mlkit/.gitignore new file mode 100644 index 00000000..96486fd9 --- /dev/null +++ b/android/flutter_plugins/qrscanner_mlkit/.gitignore @@ -0,0 +1,30 @@ +# Miscellaneous +*.class +*.log +*.pyc +*.swp +.DS_Store +.atom/ +.buildlog/ +.history +.svn/ +migrate_working_dir/ + +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ + +# The .vscode folder contains launch configuration and tasks you configure in +# VS Code which you may wish to be included in version control, so this line +# is commented out by default. +#.vscode/ + +# Flutter/Dart/Pub related +# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock. +/pubspec.lock +**/doc/api/ +.dart_tool/ +.packages +build/ diff --git a/android/flutter_plugins/qrscanner_mlkit/.metadata b/android/flutter_plugins/qrscanner_mlkit/.metadata new file mode 100644 index 00000000..d4608945 --- /dev/null +++ b/android/flutter_plugins/qrscanner_mlkit/.metadata @@ -0,0 +1,30 @@ +# This file tracks properties of this Flutter project. +# Used by Flutter tool to assess capabilities and perform upgrades etc. +# +# This file should be version controlled. + +version: + revision: 13a2fb10b838971ce211230f8ffdd094c14af02c + channel: beta + +project_type: plugin + +# Tracks metadata for the flutter migrate command +migration: + platforms: + - platform: root + create_revision: 13a2fb10b838971ce211230f8ffdd094c14af02c + base_revision: 13a2fb10b838971ce211230f8ffdd094c14af02c + - platform: android + create_revision: 13a2fb10b838971ce211230f8ffdd094c14af02c + base_revision: 13a2fb10b838971ce211230f8ffdd094c14af02c + + # User provided section + + # List of Local paths (relative to this file) that should be + # ignored by the migrate tool. + # + # Files that are not part of the templates will be ignored by default. + unmanaged_files: + - 'lib/main.dart' + - 'ios/Runner.xcodeproj/project.pbxproj' diff --git a/android/flutter_plugins/qrscanner_mlkit/CHANGELOG.md b/android/flutter_plugins/qrscanner_mlkit/CHANGELOG.md new file mode 100644 index 00000000..4788cb5b --- /dev/null +++ b/android/flutter_plugins/qrscanner_mlkit/CHANGELOG.md @@ -0,0 +1,3 @@ +## 1.0.0 + +Initial diff --git a/android/flutter_plugins/qrscanner_mlkit/LICENSE b/android/flutter_plugins/qrscanner_mlkit/LICENSE new file mode 100644 index 00000000..e69de29b diff --git a/android/flutter_plugins/qrscanner_mlkit/README.md b/android/flutter_plugins/qrscanner_mlkit/README.md new file mode 100644 index 00000000..7ea81e42 --- /dev/null +++ b/android/flutter_plugins/qrscanner_mlkit/README.md @@ -0,0 +1,4 @@ +# qscanner_mlkit + +Android-only Flutter plugin for scanning QR Codes. Implemented with ML Kit and CameraX + diff --git a/android/flutter_plugins/qrscanner_mlkit/analysis_options.yaml b/android/flutter_plugins/qrscanner_mlkit/analysis_options.yaml new file mode 100644 index 00000000..a5744c1c --- /dev/null +++ b/android/flutter_plugins/qrscanner_mlkit/analysis_options.yaml @@ -0,0 +1,4 @@ +include: package:flutter_lints/flutter.yaml + +# Additional information about this file can be found at +# https://dart.dev/guides/language/analysis-options diff --git a/android/flutter_plugins/qrscanner_mlkit/android/.gitignore b/android/flutter_plugins/qrscanner_mlkit/android/.gitignore new file mode 100644 index 00000000..161bdcda --- /dev/null +++ b/android/flutter_plugins/qrscanner_mlkit/android/.gitignore @@ -0,0 +1,9 @@ +*.iml +.gradle +/local.properties +/.idea/workspace.xml +/.idea/libraries +.DS_Store +/build +/captures +.cxx diff --git a/android/flutter_plugins/qrscanner_mlkit/android/build.gradle b/android/flutter_plugins/qrscanner_mlkit/android/build.gradle new file mode 100644 index 00000000..c347eef9 --- /dev/null +++ b/android/flutter_plugins/qrscanner_mlkit/android/build.gradle @@ -0,0 +1,61 @@ +group 'com.yubico.authenticator.flutter_plugins.qrscanner_mlkit' +version '1.0-SNAPSHOT' + +buildscript { + ext.kotlin_version = '1.6.21' + repositories { + google() + mavenCentral() + } + + dependencies { + classpath 'com.android.tools.build:gradle:7.1.3' + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + } +} + +rootProject.allprojects { + repositories { + google() + mavenCentral() + } +} + +apply plugin: 'com.android.library' +apply plugin: 'kotlin-android' + +android { + compileSdkVersion 31 + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + kotlinOptions { + jvmTarget = '1.8' + } + + sourceSets { + main.java.srcDirs += 'src/main/kotlin' + } + + defaultConfig { + minSdkVersion 21 + } +} + +dependencies { + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + + def camerax_version = "1.1.0-beta03" + + implementation "androidx.camera:camera-core:${camerax_version}" + implementation "androidx.camera:camera-camera2:${camerax_version}" + implementation "androidx.camera:camera-lifecycle:${camerax_version}" + + implementation "androidx.camera:camera-view:${camerax_version}" + implementation "androidx.camera:camera-extensions:${camerax_version}" + + implementation 'com.google.mlkit:barcode-scanning:17.0.2' +} diff --git a/android/flutter_plugins/qrscanner_mlkit/android/gradle.properties b/android/flutter_plugins/qrscanner_mlkit/android/gradle.properties new file mode 100644 index 00000000..8ab15095 --- /dev/null +++ b/android/flutter_plugins/qrscanner_mlkit/android/gradle.properties @@ -0,0 +1,15 @@ +## For more details on how to configure your build environment visit +# http://www.gradle.org/docs/current/userguide/build_environment.html +# +# Specifies the JVM arguments used for the daemon process. +# The setting is particularly useful for tweaking memory settings. +# Default value: -Xmx1024m -XX:MaxPermSize=256m +# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 +# +# When configured, Gradle will run in incubating parallel mode. +# This option should only be used with decoupled projects. More details, visit +# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects +# org.gradle.parallel=true +#Fri Apr 22 08:06:54 CEST 2022 +android.useAndroidX=true +android.enableJetifier=true diff --git a/android/flutter_plugins/qrscanner_mlkit/android/gradle/wrapper/gradle-wrapper.properties b/android/flutter_plugins/qrscanner_mlkit/android/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 00000000..595fb867 --- /dev/null +++ b/android/flutter_plugins/qrscanner_mlkit/android/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Fri Jun 23 08:50:38 CEST 2017 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-all.zip diff --git a/android/flutter_plugins/qrscanner_mlkit/android/settings.gradle b/android/flutter_plugins/qrscanner_mlkit/android/settings.gradle new file mode 100644 index 00000000..b86b9f21 --- /dev/null +++ b/android/flutter_plugins/qrscanner_mlkit/android/settings.gradle @@ -0,0 +1 @@ +rootProject.name = 'qrscanner_mlkit' diff --git a/android/flutter_plugins/qrscanner_mlkit/android/src/main/AndroidManifest.xml b/android/flutter_plugins/qrscanner_mlkit/android/src/main/AndroidManifest.xml new file mode 100644 index 00000000..0cbd1bf7 --- /dev/null +++ b/android/flutter_plugins/qrscanner_mlkit/android/src/main/AndroidManifest.xml @@ -0,0 +1,8 @@ + + + + + + + diff --git a/android/flutter_plugins/qrscanner_mlkit/android/src/main/kotlin/com/yubico/authenticator/flutter_plugins/qrscanner_mlkit/QRScannerMLKitPlugin.kt b/android/flutter_plugins/qrscanner_mlkit/android/src/main/kotlin/com/yubico/authenticator/flutter_plugins/qrscanner_mlkit/QRScannerMLKitPlugin.kt new file mode 100644 index 00000000..ce966cbb --- /dev/null +++ b/android/flutter_plugins/qrscanner_mlkit/android/src/main/kotlin/com/yubico/authenticator/flutter_plugins/qrscanner_mlkit/QRScannerMLKitPlugin.kt @@ -0,0 +1,85 @@ +package com.yubico.authenticator.flutter_plugins.qrscanner_mlkit + +import androidx.annotation.NonNull +import io.flutter.embedding.engine.plugins.FlutterPlugin +import io.flutter.embedding.engine.plugins.activity.ActivityAware +import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding +import io.flutter.plugin.common.MethodCall +import io.flutter.plugin.common.MethodChannel +import io.flutter.plugin.common.MethodChannel.MethodCallHandler +import io.flutter.plugin.common.MethodChannel.Result +import io.flutter.plugin.common.PluginRegistry + +class PermissionsResultRegistrar { + + private var permissionsResultListener: PluginRegistry.RequestPermissionsResultListener? = null + + fun setListener(listener: PluginRegistry.RequestPermissionsResultListener?) { + permissionsResultListener = listener + } + + fun onResult( + requestCode: Int, + permissions: Array, + grantResults: IntArray + ): Boolean { + return permissionsResultListener?.onRequestPermissionsResult( + requestCode, + permissions, + grantResults + ) ?: false + } +} + +/** QRScannerMLKitPlugin */ +class QRScannerMLKitPlugin : FlutterPlugin, MethodCallHandler, ActivityAware, + PluginRegistry.RequestPermissionsResultListener { + + private val registrar = PermissionsResultRegistrar() + private lateinit var channel: MethodChannel + + override fun onAttachedToEngine(@NonNull binding: FlutterPlugin.FlutterPluginBinding) { + channel = MethodChannel(binding.binaryMessenger, "qrscanner_mlkit") + channel.setMethodCallHandler(this) + + binding.platformViewRegistry + .registerViewFactory( + "qrScannerNativeView", + QRScannerViewFactory(binding.binaryMessenger, registrar) + ) + } + + override fun onMethodCall(@NonNull call: MethodCall, @NonNull result: Result) { + if (call.method == "getPlatformVersion") { + result.success("Android ${android.os.Build.VERSION.RELEASE}") + } else { + result.notImplemented() + } + } + + override fun onDetachedFromEngine(@NonNull binding: FlutterPlugin.FlutterPluginBinding) { + channel.setMethodCallHandler(null) + } + + override fun onAttachedToActivity(binding: ActivityPluginBinding) { + binding.addRequestPermissionsResultListener(this) + } + + override fun onDetachedFromActivityForConfigChanges() { + } + + override fun onReattachedToActivityForConfigChanges(binding: ActivityPluginBinding) { + + } + + override fun onDetachedFromActivity() { + } + + override fun onRequestPermissionsResult( + requestCode: Int, + permissions: Array, + grantResults: IntArray + ): Boolean { + return registrar.onResult(requestCode, permissions, grantResults) + } +} diff --git a/android/flutter_plugins/qrscanner_mlkit/android/src/main/kotlin/com/yubico/authenticator/flutter_plugins/qrscanner_mlkit/QRScannerView.kt b/android/flutter_plugins/qrscanner_mlkit/android/src/main/kotlin/com/yubico/authenticator/flutter_plugins/qrscanner_mlkit/QRScannerView.kt new file mode 100644 index 00000000..aedc6203 --- /dev/null +++ b/android/flutter_plugins/qrscanner_mlkit/android/src/main/kotlin/com/yubico/authenticator/flutter_plugins/qrscanner_mlkit/QRScannerView.kt @@ -0,0 +1,257 @@ +package com.yubico.authenticator.flutter_plugins.qrscanner_mlkit + +import android.Manifest +import android.app.Activity +import android.content.Context +import android.content.pm.PackageManager +import android.graphics.Rect +import android.opengl.Visibility +import android.util.Log +import android.view.LayoutInflater +import android.view.View +import android.widget.LinearLayout +import android.widget.TextView +import androidx.camera.core.CameraSelector +import androidx.camera.core.ImageAnalysis +import androidx.camera.core.ImageProxy +import androidx.camera.core.Preview +import androidx.camera.lifecycle.ProcessCameraProvider +import androidx.camera.view.PreviewView +import androidx.core.app.ActivityCompat +import androidx.core.content.ContextCompat +import androidx.lifecycle.LifecycleOwner +import com.google.mlkit.vision.barcode.BarcodeScannerOptions +import com.google.mlkit.vision.barcode.BarcodeScanning +import com.google.mlkit.vision.barcode.common.Barcode +import com.google.mlkit.vision.common.InputImage +import io.flutter.plugin.common.BinaryMessenger +import io.flutter.plugin.common.MethodChannel +import io.flutter.plugin.common.PluginRegistry +import io.flutter.plugin.common.StandardMessageCodec +import io.flutter.plugin.platform.PlatformView +import io.flutter.plugin.platform.PlatformViewFactory +import org.json.JSONArray +import org.json.JSONObject +import org.w3c.dom.Text +import java.util.concurrent.ExecutorService +import java.util.concurrent.Executors + +class QRScannerViewFactory( + private val binaryMessenger: BinaryMessenger, + private val permissionsResultRegistrar: PermissionsResultRegistrar +) : + PlatformViewFactory(StandardMessageCodec.INSTANCE) { + @Suppress("UNCHECKED_CAST") + override fun create(context: Context?, viewId: Int, args: Any?): PlatformView { + val creationParams = args as Map? + return QRScannerView( + context!!, + viewId, + binaryMessenger, + permissionsResultRegistrar, + creationParams + ) + } +} + +data class BarcodeInfo(val rawData: String, val rect: Rect) +typealias BarcodeAnalyzerListener = (Result>) -> Unit + +internal class QRScannerView( + context: Context, + id: Int, + binaryMessenger: BinaryMessenger, + private val permissionsResultRegistrar: PermissionsResultRegistrar, + creationParams: Map? +) : PlatformView { + + companion object { + const val TAG = "QRScannerView" + + // permission related + const val PERMISSION_REQUEST_CODE = 1 + private val PERMISSIONS_TO_REQUEST = + mutableListOf( + Manifest.permission.CAMERA, + ).toTypedArray() + + private const val CHANNEL_NAME = "com.yubico.authenticator.flutter_plugins.qr_scanner_channel" + } + + private fun allPermissionsGranted(activity: Activity) = PERMISSIONS_TO_REQUEST.all { + ContextCompat.checkSelfPermission( + activity, it + ) == PackageManager.PERMISSION_GRANTED + } + + private fun requestPermissions(activity: Activity) { + ActivityCompat.requestPermissions( + activity, + PERMISSIONS_TO_REQUEST, + PERMISSION_REQUEST_CODE + ) + } + + private val qrScannerView = LayoutInflater.from(context).inflate(R.layout.qr_scanner_view, null, false) + private val previewView = qrScannerView.findViewById(R.id.preview_view).apply { + implementationMode = PreviewView.ImplementationMode.COMPATIBLE + } + private val infoView = qrScannerView.findViewById(R.id.text_info).apply { + setText(R.string.initializing) + } + + private val cameraExecutor: ExecutorService = Executors.newSingleThreadExecutor() + private val cameraProviderFuture = ProcessCameraProvider.getInstance(context) + private var cameraProvider: ProcessCameraProvider? = null + private val cameraSelector = CameraSelector.DEFAULT_BACK_CAMERA + + private var imageAnalyzer: ImageAnalysis? = null + private var preview: Preview? = null + + override fun getView(): View { + return qrScannerView + } + + override fun dispose() { + cameraProvider?.unbindAll() + preview = null + imageAnalyzer = null + cameraExecutor.shutdown() + + Log.d(TAG, "View disposed") + } + + private val methodChannel: MethodChannel = MethodChannel(binaryMessenger, CHANNEL_NAME) + private var permissionsGranted = false + + init { + + if (context is Activity) { + permissionsGranted = allPermissionsGranted(context) + + if (!permissionsGranted) { + previewView.visibility = View.GONE + infoView.setText(R.string.initializing) + permissionsResultRegistrar.setListener( + object : PluginRegistry.RequestPermissionsResultListener { + override fun onRequestPermissionsResult( + requestCode: Int, + permissions: Array, + grantResults: IntArray + ): Boolean { + if (requestCode == PERMISSION_REQUEST_CODE) { + if (permissions.size == 1 && grantResults.size == 1) { + if (permissions.first() == PERMISSIONS_TO_REQUEST.first() && + grantResults.first() == PackageManager.PERMISSION_GRANTED + ) { + bindUseCases(context) + } else { + infoView.setText(R.string.permissions_missing) + } + } + + return true + } + + return false + } + }) + + requestPermissions(context) + + } else { + bindUseCases(context) + } + } + } + + private fun bindUseCases(context: Context) { + cameraProviderFuture.addListener({ + cameraProvider = cameraProviderFuture.get() + + cameraProvider?.unbindAll() + + imageAnalyzer = ImageAnalysis.Builder() + .setBackpressureStrategy(ImageAnalysis.STRATEGY_KEEP_ONLY_LATEST) + .build() + .also { + it.setAnalyzer(cameraExecutor, BarcodeAnalyzer { analyzeResult -> + if (analyzeResult.isSuccess) { + analyzeResult.getOrNull()?.let { result -> + val codes = JSONArray( + result.map { barcodeInfo -> + JSONObject( + mapOf( + "value" to barcodeInfo.rawData, + "location" to JSONArray( + listOf( + barcodeInfo.rect.left.toDouble(), + barcodeInfo.rect.top.toDouble(), + barcodeInfo.rect.right.toDouble(), + barcodeInfo.rect.bottom.toDouble() + ) + ) + ) + ) + } + ) + methodChannel.invokeMethod("codes", codes.toString()) + } + } + }) + } + + preview = Preview.Builder() + .build() + .also { + it.setSurfaceProvider(previewView.surfaceProvider) + } + + cameraProvider?.bindToLifecycle( + context as LifecycleOwner, + cameraSelector, + preview, imageAnalyzer + ) + + previewView.visibility = View.VISIBLE + + }, ContextCompat.getMainExecutor(context)) + } + + private class BarcodeAnalyzer(private val listener: BarcodeAnalyzerListener) : + ImageAnalysis.Analyzer { + + private val barcodeScannerOptions = BarcodeScannerOptions.Builder() + .setBarcodeFormats(Barcode.FORMAT_QR_CODE) + .build() + + private val scanner = BarcodeScanning.getClient(barcodeScannerOptions) + + override fun analyze(imageProxy: ImageProxy) { + + @androidx.camera.core.ExperimentalGetImage + val mediaImage = imageProxy.image ?: return + + val image = InputImage.fromMediaImage(mediaImage, imageProxy.imageInfo.rotationDegrees) + + scanner.process(image) + .addOnFailureListener { + listener.invoke(Result.failure(it)) + } + .addOnCompleteListener { + imageProxy.close() + + if (it.isSuccessful) { + val result = + it.result.filter { barcode -> barcode.rawValue != null && barcode.boundingBox != null } + .map { barcode -> + BarcodeInfo(barcode.rawValue!!, barcode.boundingBox!!) + } + listener.invoke(Result.success(result)) + } + } + + } + } + +} diff --git a/android/flutter_plugins/qrscanner_mlkit/android/src/main/res/layout/qr_scanner_view.xml b/android/flutter_plugins/qrscanner_mlkit/android/src/main/res/layout/qr_scanner_view.xml new file mode 100644 index 00000000..3bd9bda6 --- /dev/null +++ b/android/flutter_plugins/qrscanner_mlkit/android/src/main/res/layout/qr_scanner_view.xml @@ -0,0 +1,20 @@ + + + + + + + + \ No newline at end of file diff --git a/android/flutter_plugins/qrscanner_mlkit/android/src/main/res/values/strings.xml b/android/flutter_plugins/qrscanner_mlkit/android/src/main/res/values/strings.xml new file mode 100644 index 00000000..d191a365 --- /dev/null +++ b/android/flutter_plugins/qrscanner_mlkit/android/src/main/res/values/strings.xml @@ -0,0 +1,5 @@ + + + Permissions missing + Please wait… + \ No newline at end of file diff --git a/android/flutter_plugins/qrscanner_mlkit/example/.gitignore b/android/flutter_plugins/qrscanner_mlkit/example/.gitignore new file mode 100644 index 00000000..a8e938c0 --- /dev/null +++ b/android/flutter_plugins/qrscanner_mlkit/example/.gitignore @@ -0,0 +1,47 @@ +# Miscellaneous +*.class +*.log +*.pyc +*.swp +.DS_Store +.atom/ +.buildlog/ +.history +.svn/ +migrate_working_dir/ + +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ + +# The .vscode folder contains launch configuration and tasks you configure in +# VS Code which you may wish to be included in version control, so this line +# is commented out by default. +#.vscode/ + +# Flutter/Dart/Pub related +**/doc/api/ +**/ios/Flutter/.last_build_id +.dart_tool/ +.flutter-plugins +.flutter-plugins-dependencies +.packages +.pub-cache/ +.pub/ +/build/ + +# Web related +lib/generated_plugin_registrant.dart + +# Symbolication related +app.*.symbols + +# Obfuscation related +app.*.map.json + +# Android Studio will place build artifacts here +/android/app/debug +/android/app/profile +/android/app/release diff --git a/android/flutter_plugins/qrscanner_mlkit/example/README.md b/android/flutter_plugins/qrscanner_mlkit/example/README.md new file mode 100644 index 00000000..de814963 --- /dev/null +++ b/android/flutter_plugins/qrscanner_mlkit/example/README.md @@ -0,0 +1,16 @@ +# qrscanner_mlkit_example + +Demonstrates how to use the qrscanner_mlkit plugin. + +## Getting Started + +This project is a starting point for a Flutter application. + +A few resources to get you started if this is your first Flutter project: + +- [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab) +- [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook) + +For help getting started with Flutter development, view the +[online documentation](https://docs.flutter.dev/), which offers tutorials, +samples, guidance on mobile development, and a full API reference. diff --git a/android/flutter_plugins/qrscanner_mlkit/example/analysis_options.yaml b/android/flutter_plugins/qrscanner_mlkit/example/analysis_options.yaml new file mode 100644 index 00000000..61b6c4de --- /dev/null +++ b/android/flutter_plugins/qrscanner_mlkit/example/analysis_options.yaml @@ -0,0 +1,29 @@ +# This file configures the analyzer, which statically analyzes Dart code to +# check for errors, warnings, and lints. +# +# The issues identified by the analyzer are surfaced in the UI of Dart-enabled +# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be +# invoked from the command line by running `flutter analyze`. + +# The following line activates a set of recommended lints for Flutter apps, +# packages, and plugins designed to encourage good coding practices. +include: package:flutter_lints/flutter.yaml + +linter: + # The lint rules applied to this project can be customized in the + # section below to disable rules from the `package:flutter_lints/flutter.yaml` + # included above or to enable additional rules. A list of all available lints + # and their documentation is published at + # https://dart-lang.github.io/linter/lints/index.html. + # + # Instead of disabling a lint rule for the entire project in the + # section below, it can also be suppressed for a single line of code + # or a specific dart file by using the `// ignore: name_of_lint` and + # `// ignore_for_file: name_of_lint` syntax on the line or in the file + # producing the lint. + rules: + # avoid_print: false # Uncomment to disable the `avoid_print` rule + # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule + +# Additional information about this file can be found at +# https://dart.dev/guides/language/analysis-options diff --git a/android/flutter_plugins/qrscanner_mlkit/example/android/.gitignore b/android/flutter_plugins/qrscanner_mlkit/example/android/.gitignore new file mode 100644 index 00000000..6f568019 --- /dev/null +++ b/android/flutter_plugins/qrscanner_mlkit/example/android/.gitignore @@ -0,0 +1,13 @@ +gradle-wrapper.jar +/.gradle +/captures/ +/gradlew +/gradlew.bat +/local.properties +GeneratedPluginRegistrant.java + +# Remember to never publicly share your keystore. +# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app +key.properties +**/*.keystore +**/*.jks diff --git a/android/flutter_plugins/qrscanner_mlkit/example/android/app/build.gradle b/android/flutter_plugins/qrscanner_mlkit/example/android/app/build.gradle new file mode 100644 index 00000000..a1d87231 --- /dev/null +++ b/android/flutter_plugins/qrscanner_mlkit/example/android/app/build.gradle @@ -0,0 +1,71 @@ +def localProperties = new Properties() +def localPropertiesFile = rootProject.file('local.properties') +if (localPropertiesFile.exists()) { + localPropertiesFile.withReader('UTF-8') { reader -> + localProperties.load(reader) + } +} + +def flutterRoot = localProperties.getProperty('flutter.sdk') +if (flutterRoot == null) { + throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") +} + +def flutterVersionCode = localProperties.getProperty('flutter.versionCode') +if (flutterVersionCode == null) { + flutterVersionCode = '1' +} + +def flutterVersionName = localProperties.getProperty('flutter.versionName') +if (flutterVersionName == null) { + flutterVersionName = '1.0' +} + +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" + +android { + compileSdkVersion flutter.compileSdkVersion + ndkVersion flutter.ndkVersion + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + kotlinOptions { + jvmTarget = '1.8' + } + + sourceSets { + main.java.srcDirs += 'src/main/kotlin' + } + + defaultConfig { + // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). + applicationId "com.yubico.authenticator.flutter_plugins.qrscanner_mlkit_example" + // You can update the following values to match your application needs. + // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration. + minSdkVersion 21 + targetSdkVersion flutter.targetSdkVersion + versionCode flutterVersionCode.toInteger() + versionName flutterVersionName + } + + buildTypes { + release { + // TODO: Add your own signing config for the release build. + // Signing with the debug keys for now, so `flutter run --release` works. + signingConfig signingConfigs.debug + } + } +} + +flutter { + source '../..' +} + +dependencies { + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" +} diff --git a/android/flutter_plugins/qrscanner_mlkit/example/android/app/src/debug/AndroidManifest.xml b/android/flutter_plugins/qrscanner_mlkit/example/android/app/src/debug/AndroidManifest.xml new file mode 100644 index 00000000..b4b75bcc --- /dev/null +++ b/android/flutter_plugins/qrscanner_mlkit/example/android/app/src/debug/AndroidManifest.xml @@ -0,0 +1,8 @@ + + + + diff --git a/android/flutter_plugins/qrscanner_mlkit/example/android/app/src/main/AndroidManifest.xml b/android/flutter_plugins/qrscanner_mlkit/example/android/app/src/main/AndroidManifest.xml new file mode 100644 index 00000000..e0ab2d1f --- /dev/null +++ b/android/flutter_plugins/qrscanner_mlkit/example/android/app/src/main/AndroidManifest.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + diff --git a/android/flutter_plugins/qrscanner_mlkit/example/android/app/src/main/kotlin/com/yubico/authenticator/flutter_plugins/qrscanner_mlkit_example/MainActivity.kt b/android/flutter_plugins/qrscanner_mlkit/example/android/app/src/main/kotlin/com/yubico/authenticator/flutter_plugins/qrscanner_mlkit_example/MainActivity.kt new file mode 100644 index 00000000..8d3aef52 --- /dev/null +++ b/android/flutter_plugins/qrscanner_mlkit/example/android/app/src/main/kotlin/com/yubico/authenticator/flutter_plugins/qrscanner_mlkit_example/MainActivity.kt @@ -0,0 +1,6 @@ +package com.yubico.authenticator.flutter_plugins.qrscanner_mlkit_example + +import io.flutter.embedding.android.FlutterActivity + +class MainActivity: FlutterActivity() { +} diff --git a/android/flutter_plugins/qrscanner_mlkit/example/android/app/src/main/res/drawable-v21/launch_background.xml b/android/flutter_plugins/qrscanner_mlkit/example/android/app/src/main/res/drawable-v21/launch_background.xml new file mode 100644 index 00000000..f74085f3 --- /dev/null +++ b/android/flutter_plugins/qrscanner_mlkit/example/android/app/src/main/res/drawable-v21/launch_background.xml @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/android/flutter_plugins/qrscanner_mlkit/example/android/app/src/main/res/drawable/launch_background.xml b/android/flutter_plugins/qrscanner_mlkit/example/android/app/src/main/res/drawable/launch_background.xml new file mode 100644 index 00000000..304732f8 --- /dev/null +++ b/android/flutter_plugins/qrscanner_mlkit/example/android/app/src/main/res/drawable/launch_background.xml @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/android/flutter_plugins/qrscanner_mlkit/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png b/android/flutter_plugins/qrscanner_mlkit/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..db77bb4b7b0906d62b1847e87f15cdcacf6a4f29 GIT binary patch literal 544 zcmeAS@N?(olHy`uVBq!ia0vp^9w5xY3?!3`olAj~WQl7;NpOBzNqJ&XDuZK6ep0G} zXKrG8YEWuoN@d~6R2!h8bpbvhu0Wd6uZuB!w&u2PAxD2eNXD>P5D~Wn-+_Wa#27Xc zC?Zj|6r#X(-D3u$NCt}(Ms06KgJ4FxJVv{GM)!I~&n8Bnc94O7-Hd)cjDZswgC;Qs zO=b+9!WcT8F?0rF7!Uys2bs@gozCP?z~o%U|N3vA*22NaGQG zlg@K`O_XuxvZ&Ks^m&R!`&1=spLvfx7oGDKDwpwW`#iqdw@AL`7MR}m`rwr|mZgU`8P7SBkL78fFf!WnuYWm$5Z0 zNXhDbCv&49sM544K|?c)WrFfiZvCi9h0O)B3Pgg&ebxsLQ05GG~ AQ2+n{ literal 0 HcmV?d00001 diff --git a/android/flutter_plugins/qrscanner_mlkit/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png b/android/flutter_plugins/qrscanner_mlkit/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..17987b79bb8a35cc66c3c1fd44f5a5526c1b78be GIT binary patch literal 442 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA3?vioaBc-sk|nMYCBgY=CFO}lsSJ)O`AMk? zp1FzXsX?iUDV2pMQ*D5Xx&nMcT!A!W`0S9QKQy;}1Cl^CgaH=;G9cpY;r$Q>i*pfB zP2drbID<_#qf;rPZx^FqH)F_D#*k@@q03KywUtLX8Ua?`H+NMzkczFPK3lFz@i_kW%1NOn0|D2I9n9wzH8m|-tHjsw|9>@K=iMBhxvkv6m8Y-l zytQ?X=U+MF$@3 zt`~i=@j|6y)RWMK--}M|=T`o&^Ni>IoWKHEbBXz7?A@mgWoL>!*SXo`SZH-*HSdS+ yn*9;$7;m`l>wYBC5bq;=U}IMqLzqbYCidGC!)_gkIk_C@Uy!y&wkt5C($~2D>~)O*cj@FGjOCM)M>_ixfudOh)?xMu#Fs z#}Y=@YDTwOM)x{K_j*Q;dPdJ?Mz0n|pLRx{4n|)f>SXlmV)XB04CrSJn#dS5nK2lM zrZ9#~WelCp7&e13Y$jvaEXHskn$2V!!DN-nWS__6T*l;H&Fopn?A6HZ-6WRLFP=R` zqG+CE#d4|IbyAI+rJJ`&x9*T`+a=p|0O(+s{UBcyZdkhj=yS1>AirP+0R;mf2uMgM zC}@~JfByORAh4SyRgi&!(cja>F(l*O+nd+@4m$|6K6KDn_&uvCpV23&>G9HJp{xgg zoq1^2_p9@|WEo z*X_Uko@K)qYYv~>43eQGMdbiGbo>E~Q& zrYBH{QP^@Sti!`2)uG{irBBq@y*$B zi#&(U-*=fp74j)RyIw49+0MRPMRU)+a2r*PJ$L5roHt2$UjExCTZSbq%V!HeS7J$N zdG@vOZB4v_lF7Plrx+hxo7(fCV&}fHq)$ literal 0 HcmV?d00001 diff --git a/android/flutter_plugins/qrscanner_mlkit/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/android/flutter_plugins/qrscanner_mlkit/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..d5f1c8d34e7a88e3f88bea192c3a370d44689c3c GIT binary patch literal 1031 zcmeAS@N?(olHy`uVBq!ia0vp^6F``Q8Ax83A=Cw=BuiW)N`mv#O3D+9QW+dm@{>{( zJaZG%Q-e|yQz{EjrrIztFa`(sgt!6~Yi|1%a`XoT0ojZ}lNrNjb9xjc(B0U1_% zz5^97Xt*%oq$rQy4?0GKNfJ44uvxI)gC`h-NZ|&0-7(qS@?b!5r36oQ}zyZrNO3 zMO=Or+<~>+A&uN&E!^Sl+>xE!QC-|oJv`ApDhqC^EWD|@=#J`=d#Xzxs4ah}w&Jnc z$|q_opQ^2TrnVZ0o~wh<3t%W&flvYGe#$xqda2bR_R zvPYgMcHgjZ5nSA^lJr%;<&0do;O^tDDh~=pIxA#coaCY>&N%M2^tq^U%3DB@ynvKo}b?yu-bFc-u0JHzced$sg7S3zqI(2 z#Km{dPr7I=pQ5>FuK#)QwK?Y`E`B?nP+}U)I#c1+FM*1kNvWG|a(TpksZQ3B@sD~b zpQ2)*V*TdwjFOtHvV|;OsiDqHi=6%)o4b!)x$)%9pGTsE z-JL={-Ffv+T87W(Xpooq<`r*VzWQcgBN$$`u}f>-ZQI1BB8ykN*=e4rIsJx9>z}*o zo~|9I;xof literal 0 HcmV?d00001 diff --git a/android/flutter_plugins/qrscanner_mlkit/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/android/flutter_plugins/qrscanner_mlkit/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..4d6372eebdb28e45604e46eeda8dd24651419bc0 GIT binary patch literal 1443 zcmb`G{WsKk6vsdJTdFg%tJav9_E4vzrOaqkWF|A724Nly!y+?N9`YV6wZ}5(X(D_N(?!*n3`|_r0Hc?=PQw&*vnU?QTFY zB_MsH|!j$PP;I}?dppoE_gA(4uc!jV&0!l7_;&p2^pxNo>PEcNJv za5_RT$o2Mf!<+r?&EbHH6nMoTsDOa;mN(wv8RNsHpG)`^ymG-S5By8=l9iVXzN_eG%Xg2@Xeq76tTZ*dGh~Lo9vl;Zfs+W#BydUw zCkZ$o1LqWQO$FC9aKlLl*7x9^0q%0}$OMlp@Kk_jHXOjofdePND+j!A{q!8~Jn+s3 z?~~w@4?egS02}8NuulUA=L~QQfm;MzCGd)XhiftT;+zFO&JVyp2mBww?;QByS_1w! zrQlx%{^cMj0|Bo1FjwY@Q8?Hx0cIPF*@-ZRFpPc#bBw{5@tD(5%sClzIfl8WU~V#u zm5Q;_F!wa$BSpqhN>W@2De?TKWR*!ujY;Yylk_X5#~V!L*Gw~;$%4Q8~Mad z@`-kG?yb$a9cHIApZDVZ^U6Xkp<*4rU82O7%}0jjHlK{id@?-wpN*fCHXyXh(bLt* zPc}H-x0e4E&nQ>y%B-(EL=9}RyC%MyX=upHuFhAk&MLbsF0LP-q`XnH78@fT+pKPW zu72MW`|?8ht^tz$iC}ZwLp4tB;Q49K!QCF3@!iB1qOI=?w z7In!}F~ij(18UYUjnbmC!qKhPo%24?8U1x{7o(+?^Zu0Hx81|FuS?bJ0jgBhEMzf< zCgUq7r2OCB(`XkKcN-TL>u5y#dD6D!)5W?`O5)V^>jb)P)GBdy%t$uUMpf$SNV31$ zb||OojAbvMP?T@$h_ZiFLFVHDmbyMhJF|-_)HX3%m=CDI+ID$0^C>kzxprBW)hw(v zr!Gmda);ICoQyhV_oP5+C%?jcG8v+D@9f?Dk*!BxY}dazmrT@64UrP3hlslANK)bq z$67n83eh}OeW&SV@HG95P|bjfqJ7gw$e+`Hxo!4cx`jdK1bJ>YDSpGKLPZ^1cv$ek zIB?0S<#tX?SJCLWdMd{-ME?$hc7A$zBOdIJ)4!KcAwb=VMov)nK;9z>x~rfT1>dS+ zZ6#`2v@`jgbqq)P22H)Tx2CpmM^o1$B+xT6`(v%5xJ(?j#>Q$+rx_R|7TzDZe{J6q zG1*EcU%tE?!kO%^M;3aM6JN*LAKUVb^xz8-Pxo#jR5(-KBeLJvA@-gxNHx0M-ZJLl z;#JwQoh~9V?`UVo#}{6ka@II>++D@%KqGpMdlQ}?9E*wFcf5(#XQnP$Dk5~%iX^>f z%$y;?M0BLp{O3a(-4A?ewryHrrD%cx#Q^%KY1H zNre$ve+vceSLZcNY4U(RBX&)oZn*Py()h)XkE?PL$!bNb{N5FVI2Y%LKEm%yvpyTP z(1P?z~7YxD~Rf<(a@_y` literal 0 HcmV?d00001 diff --git a/android/flutter_plugins/qrscanner_mlkit/example/android/app/src/main/res/values-night/styles.xml b/android/flutter_plugins/qrscanner_mlkit/example/android/app/src/main/res/values-night/styles.xml new file mode 100644 index 00000000..06952be7 --- /dev/null +++ b/android/flutter_plugins/qrscanner_mlkit/example/android/app/src/main/res/values-night/styles.xml @@ -0,0 +1,18 @@ + + + + + + + diff --git a/android/flutter_plugins/qrscanner_mlkit/example/android/app/src/main/res/values/styles.xml b/android/flutter_plugins/qrscanner_mlkit/example/android/app/src/main/res/values/styles.xml new file mode 100644 index 00000000..cb1ef880 --- /dev/null +++ b/android/flutter_plugins/qrscanner_mlkit/example/android/app/src/main/res/values/styles.xml @@ -0,0 +1,18 @@ + + + + + + + diff --git a/android/flutter_plugins/qrscanner_mlkit/example/android/app/src/profile/AndroidManifest.xml b/android/flutter_plugins/qrscanner_mlkit/example/android/app/src/profile/AndroidManifest.xml new file mode 100644 index 00000000..b4b75bcc --- /dev/null +++ b/android/flutter_plugins/qrscanner_mlkit/example/android/app/src/profile/AndroidManifest.xml @@ -0,0 +1,8 @@ + + + + diff --git a/android/flutter_plugins/qrscanner_mlkit/example/android/build.gradle b/android/flutter_plugins/qrscanner_mlkit/example/android/build.gradle new file mode 100644 index 00000000..83ae2200 --- /dev/null +++ b/android/flutter_plugins/qrscanner_mlkit/example/android/build.gradle @@ -0,0 +1,31 @@ +buildscript { + ext.kotlin_version = '1.6.10' + repositories { + google() + mavenCentral() + } + + dependencies { + classpath 'com.android.tools.build:gradle:7.1.2' + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + } +} + +allprojects { + repositories { + google() + mavenCentral() + } +} + +rootProject.buildDir = '../build' +subprojects { + project.buildDir = "${rootProject.buildDir}/${project.name}" +} +subprojects { + project.evaluationDependsOn(':app') +} + +task clean(type: Delete) { + delete rootProject.buildDir +} diff --git a/android/flutter_plugins/qrscanner_mlkit/example/android/gradle.properties b/android/flutter_plugins/qrscanner_mlkit/example/android/gradle.properties new file mode 100644 index 00000000..94adc3a3 --- /dev/null +++ b/android/flutter_plugins/qrscanner_mlkit/example/android/gradle.properties @@ -0,0 +1,3 @@ +org.gradle.jvmargs=-Xmx1536M +android.useAndroidX=true +android.enableJetifier=true diff --git a/android/flutter_plugins/qrscanner_mlkit/example/android/gradle/wrapper/gradle-wrapper.properties b/android/flutter_plugins/qrscanner_mlkit/example/android/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 00000000..cc5527d7 --- /dev/null +++ b/android/flutter_plugins/qrscanner_mlkit/example/android/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Fri Jun 23 08:50:38 CEST 2017 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip diff --git a/android/flutter_plugins/qrscanner_mlkit/example/android/settings.gradle b/android/flutter_plugins/qrscanner_mlkit/example/android/settings.gradle new file mode 100644 index 00000000..44e62bcf --- /dev/null +++ b/android/flutter_plugins/qrscanner_mlkit/example/android/settings.gradle @@ -0,0 +1,11 @@ +include ':app' + +def localPropertiesFile = new File(rootProject.projectDir, "local.properties") +def properties = new Properties() + +assert localPropertiesFile.exists() +localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } + +def flutterSdkPath = properties.getProperty("flutter.sdk") +assert flutterSdkPath != null, "flutter.sdk not set in local.properties" +apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle" diff --git a/android/flutter_plugins/qrscanner_mlkit/example/lib/main.dart b/android/flutter_plugins/qrscanner_mlkit/example/lib/main.dart new file mode 100644 index 00000000..10337966 --- /dev/null +++ b/android/flutter_plugins/qrscanner_mlkit/example/lib/main.dart @@ -0,0 +1,62 @@ +import 'dart:async'; + +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:qrscanner_mlkit/qrscanner_mlkit.dart'; + +void main() { + runApp(const MyApp()); +} + +class MyApp extends StatefulWidget { + const MyApp({Key? key}) : super(key: key); + + @override + State createState() => _MyAppState(); +} + +class _MyAppState extends State { + String _platformVersion = 'Unknown'; + final _qrscannerMlkitPlugin = QRScannerMLKit(); + + @override + void initState() { + super.initState(); + initPlatformState(); + } + + // Platform messages are asynchronous, so we initialize in an async method. + Future initPlatformState() async { + String platformVersion; + // Platform messages may fail, so we use a try/catch PlatformException. + // We also handle the message potentially returning null. + try { + platformVersion = await _qrscannerMlkitPlugin.getPlatformVersion() ?? 'Unknown platform version'; + } on PlatformException { + platformVersion = 'Failed to get platform version.'; + } + + // If the widget was removed from the tree while the asynchronous platform + // message was in flight, we want to discard the reply rather than calling + // setState to update our non-existent appearance. + if (!mounted) return; + + setState(() { + _platformVersion = platformVersion; + }); + } + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar( + title: const Text('Plugin example app'), + ), + body: Center( + child: Text('Running on: $_platformVersion\n'), + ), + ), + ); + } +} diff --git a/android/flutter_plugins/qrscanner_mlkit/example/pubspec.lock b/android/flutter_plugins/qrscanner_mlkit/example/pubspec.lock new file mode 100644 index 00000000..a266dc77 --- /dev/null +++ b/android/flutter_plugins/qrscanner_mlkit/example/pubspec.lock @@ -0,0 +1,182 @@ +# Generated by pub +# See https://dart.dev/tools/pub/glossary#lockfile +packages: + async: + dependency: transitive + description: + name: async + url: "https://pub.dartlang.org" + source: hosted + version: "2.8.2" + boolean_selector: + dependency: transitive + description: + name: boolean_selector + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.0" + characters: + dependency: transitive + description: + name: characters + url: "https://pub.dartlang.org" + source: hosted + version: "1.2.0" + charcode: + dependency: transitive + description: + name: charcode + url: "https://pub.dartlang.org" + source: hosted + version: "1.3.1" + clock: + dependency: transitive + description: + name: clock + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.0" + collection: + dependency: transitive + description: + name: collection + url: "https://pub.dartlang.org" + source: hosted + version: "1.16.0" + cupertino_icons: + dependency: "direct main" + description: + name: cupertino_icons + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.4" + fake_async: + dependency: transitive + description: + name: fake_async + url: "https://pub.dartlang.org" + source: hosted + version: "1.3.0" + flutter: + dependency: "direct main" + description: flutter + source: sdk + version: "0.0.0" + flutter_lints: + dependency: "direct dev" + description: + name: flutter_lints + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.1" + flutter_test: + dependency: "direct dev" + description: flutter + source: sdk + version: "0.0.0" + lints: + dependency: transitive + description: + name: lints + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.0" + matcher: + dependency: transitive + description: + name: matcher + url: "https://pub.dartlang.org" + source: hosted + version: "0.12.11" + material_color_utilities: + dependency: transitive + description: + name: material_color_utilities + url: "https://pub.dartlang.org" + source: hosted + version: "0.1.4" + meta: + dependency: transitive + description: + name: meta + url: "https://pub.dartlang.org" + source: hosted + version: "1.7.0" + path: + dependency: transitive + description: + name: path + url: "https://pub.dartlang.org" + source: hosted + version: "1.8.1" + plugin_platform_interface: + dependency: transitive + description: + name: plugin_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.2" + qrscanner_mlkit: + dependency: "direct main" + description: + path: ".." + relative: true + source: path + version: "1.0.0" + sky_engine: + dependency: transitive + description: flutter + source: sdk + version: "0.0.99" + source_span: + dependency: transitive + description: + name: source_span + url: "https://pub.dartlang.org" + source: hosted + version: "1.8.2" + stack_trace: + dependency: transitive + description: + name: stack_trace + url: "https://pub.dartlang.org" + source: hosted + version: "1.10.0" + stream_channel: + dependency: transitive + description: + name: stream_channel + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.0" + string_scanner: + dependency: transitive + description: + name: string_scanner + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.0" + term_glyph: + dependency: transitive + description: + name: term_glyph + url: "https://pub.dartlang.org" + source: hosted + version: "1.2.0" + test_api: + dependency: transitive + description: + name: test_api + url: "https://pub.dartlang.org" + source: hosted + version: "0.4.9" + vector_math: + dependency: transitive + description: + name: vector_math + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.2" +sdks: + dart: ">=2.17.0-266.1.beta <3.0.0" + flutter: ">=2.5.0" diff --git a/android/flutter_plugins/qrscanner_mlkit/example/pubspec.yaml b/android/flutter_plugins/qrscanner_mlkit/example/pubspec.yaml new file mode 100644 index 00000000..53f900d9 --- /dev/null +++ b/android/flutter_plugins/qrscanner_mlkit/example/pubspec.yaml @@ -0,0 +1,24 @@ +name: qrscanner_mlkit_example +description: Demonstrates how to use the qrscanner_mlkit plugin. + +publish_to: 'none' # Remove this line if you wish to publish to pub.dev + +environment: + sdk: ">=2.17.0-266.1.beta <3.0.0" + +dependencies: + flutter: + sdk: flutter + + qrscanner_mlkit: + path: ../ + + cupertino_icons: ^1.0.2 + +dev_dependencies: + flutter_test: + sdk: flutter + flutter_lints: ^2.0.0 + +flutter: + uses-material-design: true \ No newline at end of file diff --git a/android/flutter_plugins/qrscanner_mlkit/example/test/widget_test.dart b/android/flutter_plugins/qrscanner_mlkit/example/test/widget_test.dart new file mode 100644 index 00000000..d214628f --- /dev/null +++ b/android/flutter_plugins/qrscanner_mlkit/example/test/widget_test.dart @@ -0,0 +1,27 @@ +// This is a basic Flutter widget test. +// +// To perform an interaction with a widget in your test, use the WidgetTester +// utility in the flutter_test package. For example, you can send tap and scroll +// gestures. You can also use WidgetTester to find child widgets in the widget +// tree, read text, and verify that the values of widget properties are correct. + +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; + +import '../lib/main.dart'; + +void main() { + testWidgets('Verify Platform version', (WidgetTester tester) async { + // Build our app and trigger a frame. + await tester.pumpWidget(const MyApp()); + + // Verify that platform version is retrieved. + expect( + find.byWidgetPredicate( + (Widget widget) => + widget is Text && widget.data!.startsWith('Running on:'), + ), + findsOneWidget, + ); + }); +} diff --git a/android/flutter_plugins/qrscanner_mlkit/lib/qrscanner_mlkit.dart b/android/flutter_plugins/qrscanner_mlkit/lib/qrscanner_mlkit.dart new file mode 100644 index 00000000..0789cb04 --- /dev/null +++ b/android/flutter_plugins/qrscanner_mlkit/lib/qrscanner_mlkit.dart @@ -0,0 +1,7 @@ +import 'qrscanner_mlkit_platform_interface.dart'; + +class QRScannerMLKit { + Future getPlatformVersion() { + return QRScannerMLKitPlatform.instance.getPlatformVersion(); + } +} diff --git a/android/flutter_plugins/qrscanner_mlkit/lib/qrscanner_mlkit_method_channel.dart b/android/flutter_plugins/qrscanner_mlkit/lib/qrscanner_mlkit_method_channel.dart new file mode 100644 index 00000000..4e4c5390 --- /dev/null +++ b/android/flutter_plugins/qrscanner_mlkit/lib/qrscanner_mlkit_method_channel.dart @@ -0,0 +1,17 @@ +import 'package:flutter/foundation.dart'; +import 'package:flutter/services.dart'; + +import 'qrscanner_mlkit_platform_interface.dart'; + +/// An implementation of [QRScannerMLKitPlatform] that uses method channels. +class MethodChannelQRScannerMLKit extends QRScannerMLKitPlatform { + /// The method channel used to interact with the native platform. + @visibleForTesting + final methodChannel = const MethodChannel('qrscanner_mlkit'); + + @override + Future getPlatformVersion() async { + final version = await methodChannel.invokeMethod('getPlatformVersion'); + return version; + } +} diff --git a/android/flutter_plugins/qrscanner_mlkit/lib/qrscanner_mlkit_platform_interface.dart b/android/flutter_plugins/qrscanner_mlkit/lib/qrscanner_mlkit_platform_interface.dart new file mode 100644 index 00000000..bfb6ac43 --- /dev/null +++ b/android/flutter_plugins/qrscanner_mlkit/lib/qrscanner_mlkit_platform_interface.dart @@ -0,0 +1,29 @@ +import 'package:plugin_platform_interface/plugin_platform_interface.dart'; + +import 'qrscanner_mlkit_method_channel.dart'; + +abstract class QRScannerMLKitPlatform extends PlatformInterface { + /// Constructs a QRScannerMLKitPlatform. + QRScannerMLKitPlatform() : super(token: _token); + + static final Object _token = Object(); + + static QRScannerMLKitPlatform _instance = MethodChannelQRScannerMLKit(); + + /// The default instance of [QRScannerMLKitPlatform] to use. + /// + /// Defaults to [MethodChannelQRScannerMLKit]. + static QRScannerMLKitPlatform get instance => _instance; + + /// Platform-specific implementations should set this with their own + /// platform-specific class that extends [QRScannerMLKitPlatform] when + /// they register themselves. + static set instance(QRScannerMLKitPlatform instance) { + PlatformInterface.verifyToken(instance, _token); + _instance = instance; + } + + Future getPlatformVersion() { + throw UnimplementedError('platformVersion() has not been implemented.'); + } +} diff --git a/android/flutter_plugins/qrscanner_mlkit/lib/qrscanner_mlkit_view.dart b/android/flutter_plugins/qrscanner_mlkit/lib/qrscanner_mlkit_view.dart new file mode 100644 index 00000000..76e3a51e --- /dev/null +++ b/android/flutter_plugins/qrscanner_mlkit/lib/qrscanner_mlkit_view.dart @@ -0,0 +1,70 @@ +import 'dart:convert'; + +import 'package:flutter/foundation.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; + +class ScannedData { + final String data; + final Rect location; + + ScannedData(this.data, this.location); +} + +class QrScannerMLKitView extends StatefulWidget { + final Function(ScannedData data) onDetect; + const QrScannerMLKitView({Key? key, required this.onDetect}) + : super(key: key); + + @override + QrScannerMLKitViewState createState() => QrScannerMLKitViewState(); +} + +class QrScannerMLKitViewState extends State { + final MethodChannel channel = const MethodChannel( + "com.yubico.authenticator.flutter_plugins.qr_scanner_channel"); + + QrScannerMLKitViewState() : super() { + channel.setMethodCallHandler((call) async { + try { + var barcodes = jsonDecode(call.arguments); + if (barcodes is List && barcodes.isNotEmpty) { + var firstBarcode = barcodes[0]; + var rawValue = firstBarcode["value"]; + var location = firstBarcode["location"]; + double l = location[0].toDouble(); + double t = location[1].toDouble(); + double r = location[2].toDouble(); + double b = location[3].toDouble(); + var locationRect = Rect.fromLTRB(l, t, r, b); + widget.onDetect(ScannedData(rawValue, locationRect)); + } + } catch (e) { + print("Exception on receive: $e"); + } + }); + } + + @override + void dispose() { + super.dispose(); + channel.setMethodCallHandler(null); + } + + @override + Widget build(BuildContext context) { + if (kDebugMode) { + print("Building QrScannerView"); + } + + const String viewType = 'qrScannerNativeView'; + final Map creationParams = {}; + + return AndroidView( + viewType: viewType, + layoutDirection: TextDirection.ltr, + creationParams: creationParams, + creationParamsCodec: const StandardMessageCodec(), + ); + } +} diff --git a/android/flutter_plugins/qrscanner_mlkit/pubspec.yaml b/android/flutter_plugins/qrscanner_mlkit/pubspec.yaml new file mode 100644 index 00000000..f9387d30 --- /dev/null +++ b/android/flutter_plugins/qrscanner_mlkit/pubspec.yaml @@ -0,0 +1,25 @@ +name: qrscanner_mlkit +description: Android-only QR Scanner plugin based on ML Kit and CameraX API's +version: 1.0.0 +homepage: + +environment: + sdk: ">=2.17.0-266.1.beta <3.0.0" + flutter: ">=2.5.0" + +dependencies: + flutter: + sdk: flutter + plugin_platform_interface: ^2.0.2 + +dev_dependencies: + flutter_test: + sdk: flutter + flutter_lints: ^2.0.0 + +flutter: + plugin: + platforms: + android: + package: com.yubico.authenticator.flutter_plugins.qrscanner_mlkit + pluginClass: QRScannerMLKitPlugin \ No newline at end of file diff --git a/android/flutter_plugins/qrscanner_mlkit/test/qrscanner_mlkit_method_channel_test.dart b/android/flutter_plugins/qrscanner_mlkit/test/qrscanner_mlkit_method_channel_test.dart new file mode 100644 index 00000000..05d20192 --- /dev/null +++ b/android/flutter_plugins/qrscanner_mlkit/test/qrscanner_mlkit_method_channel_test.dart @@ -0,0 +1,24 @@ +import 'package:flutter/services.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:qrscanner_mlkit/qrscanner_mlkit_method_channel.dart'; + +void main() { + MethodChannelQRScannerMLKit platform = MethodChannelQRScannerMLKit(); + const MethodChannel channel = MethodChannel('qrscanner_mlkit'); + + TestWidgetsFlutterBinding.ensureInitialized(); + + setUp(() { + channel.setMockMethodCallHandler((MethodCall methodCall) async { + return '42'; + }); + }); + + tearDown(() { + channel.setMockMethodCallHandler(null); + }); + + test('getPlatformVersion', () async { + expect(await platform.getPlatformVersion(), '42'); + }); +} diff --git a/android/flutter_plugins/qrscanner_mlkit/test/qrscanner_mlkit_test.dart b/android/flutter_plugins/qrscanner_mlkit/test/qrscanner_mlkit_test.dart new file mode 100644 index 00000000..45098c52 --- /dev/null +++ b/android/flutter_plugins/qrscanner_mlkit/test/qrscanner_mlkit_test.dart @@ -0,0 +1,26 @@ +import 'package:flutter_test/flutter_test.dart'; +import 'package:plugin_platform_interface/plugin_platform_interface.dart'; +import 'package:qrscanner_mlkit/qrscanner_mlkit.dart'; +import 'package:qrscanner_mlkit/qrscanner_mlkit_method_channel.dart'; +import 'package:qrscanner_mlkit/qrscanner_mlkit_platform_interface.dart'; + +class MockQRScannerMLKitPlatform with MockPlatformInterfaceMixin implements QRScannerMLKitPlatform { + @override + Future getPlatformVersion() => Future.value('42'); +} + +void main() { + final QRScannerMLKitPlatform initialPlatform = QRScannerMLKitPlatform.instance; + + test('$MethodChannelQRScannerMLKit is the default instance', () { + expect(initialPlatform, isInstanceOf()); + }); + + test('getPlatformVersion', () async { + QRScannerMLKit qrscannerMlkitPlugin = QRScannerMLKit(); + MockQRScannerMLKitPlatform fakePlatform = MockQRScannerMLKitPlatform(); + QRScannerMLKitPlatform.instance = fakePlatform; + + expect(await qrscannerMlkitPlugin.getPlatformVersion(), '42'); + }); +} diff --git a/lib/android/qr_scanner/qr_scanner_view.dart b/lib/android/qr_scanner/qr_scanner_view.dart index 9f4cb6c6..4aa7ebb3 100755 --- a/lib/android/qr_scanner/qr_scanner_view.dart +++ b/lib/android/qr_scanner/qr_scanner_view.dart @@ -1,5 +1,5 @@ import 'package:flutter/material.dart'; -import 'package:mobile_scanner/mobile_scanner.dart'; +import 'package:qrscanner_mlkit/qrscanner_mlkit_view.dart'; import '../../app/navigation_service.dart'; import '../../oath/models.dart'; @@ -29,13 +29,11 @@ class OverlayClipper extends CustomClipper { } class MobileScannerWrapper extends StatelessWidget { - final MobileScannerController controller; - final Function(Barcode barcode, MobileScannerArguments? args)? onDetect; + final Function(ScannedData) onDetect; final _ScanStatus status; const MobileScannerWrapper({ Key? key, - required this.controller, required this.onDetect, required this.status, }) : super(key: key); @@ -55,12 +53,9 @@ class MobileScannerWrapper extends StatelessWidget { height: size.width - 38); return Stack(children: [ - MobileScanner( - controller: controller, - allowDuplicates: true, - onDetect: (barcode, args) { - onDetect?.call(barcode, args); - }), + QrScannerMLKitView(onDetect: (scannedData) { + onDetect.call(scannedData); + }), ClipPath( clipper: OverlayClipper(), child: Opacity( @@ -108,9 +103,6 @@ class _QrScannerViewState extends State { CredentialData? _credentialData; _ScanStatus _status = _ScanStatus.looking; - final MobileScannerController _controller = - MobileScannerController(facing: CameraFacing.back, torchEnabled: false); - void setError() { _credentialData = null; _scannedString = null; @@ -129,13 +121,14 @@ class _QrScannerViewState extends State { }); } - void handleResult(String? code, MobileScannerArguments? args) { + void handleResult(ScannedData scannedData) { if (_status != _ScanStatus.looking) { // on success and error ignore reported codes return; } setState(() { - if (code != null) { + if (scannedData.data.isNotEmpty) { + var code = scannedData.data; try { var parsedCredential = CredentialData.fromUri(Uri.parse(code)); _credentialData = parsedCredential; @@ -175,10 +168,8 @@ class _QrScannerViewState extends State { ), body: Stack(children: [ MobileScannerWrapper( - controller: _controller, status: _status, - onDetect: (barcode, args) => - handleResult(barcode.rawValue, args), + onDetect: (scannedData) => handleResult(scannedData), ), Padding( padding: diff --git a/pubspec.lock b/pubspec.lock index a8a52c2f..00c3e1c0 100755 --- a/pubspec.lock +++ b/pubspec.lock @@ -352,15 +352,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.0.1" - mobile_scanner: - dependency: "direct main" - description: - path: "." - ref: just-android - resolved-ref: b5473703e1e9c845dfedf129d394d0535367c9e6 - url: "https://github.com/AdamVe/mobile_scanner.git" - source: git - version: "1.0.0" package_config: dependency: transitive description: @@ -445,6 +436,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.2.0" + qrscanner_mlkit: + dependency: "direct main" + description: + path: "android/flutter_plugins/qrscanner_mlkit" + relative: true + source: path + version: "1.0.0" riverpod: dependency: transitive description: @@ -661,5 +659,5 @@ packages: source: hosted version: "3.1.0" sdks: - dart: ">=2.17.0-0 <3.0.0" + dart: ">=2.17.0-266.1.beta <3.0.0" flutter: ">=2.8.0" diff --git a/pubspec.yaml b/pubspec.yaml index 9a3dc65b..9f69d8c7 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -42,10 +42,8 @@ dependencies: json_annotation: ^4.4.0 freezed_annotation: ^1.0.0 window_manager: ^0.2.0 - mobile_scanner: - git: - url: https://github.com/AdamVe/mobile_scanner.git - ref: just-android + qrscanner_mlkit: + path: ./android/flutter_plugins/qrscanner_mlkit desktop_drop: ^0.3.3 dev_dependencies: