imp: upgrade compile sdk, fix custom frameflutter-beta
| @@ -1 +1 @@ | |||||
| include: package:pedantic/analysis_options.yaml | |||||
| include: package:flutter_lints/flutter.yaml | |||||
| @@ -2,14 +2,14 @@ group 'net.touchcapture.qr.flutterqr' | |||||
| version '1.0-SNAPSHOT' | version '1.0-SNAPSHOT' | ||||
| buildscript { | buildscript { | ||||
| ext.kotlin_version = '1.5.10' | |||||
| ext.kotlin_version = '1.5.31' | |||||
| repositories { | repositories { | ||||
| google() | google() | ||||
| mavenCentral() | mavenCentral() | ||||
| } | } | ||||
| dependencies { | dependencies { | ||||
| classpath 'com.android.tools.build:gradle:4.2.1' | |||||
| classpath 'com.android.tools.build:gradle:7.0.2' | |||||
| classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" | ||||
| } | } | ||||
| } | } | ||||
| @@ -36,9 +36,7 @@ android { | |||||
| testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | ||||
| multiDexEnabled true | multiDexEnabled true | ||||
| } | } | ||||
| buildFeatures { | |||||
| viewBinding = true | |||||
| } | |||||
| compileOptions { | compileOptions { | ||||
| // Flag to enable support for the new language APIs | // Flag to enable support for the new language APIs | ||||
| coreLibraryDesugaringEnabled true | coreLibraryDesugaringEnabled true | ||||
| @@ -1,4 +1,4 @@ | |||||
| <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="net.touchcapture.qr.flutterqr" | |||||
| xmlns:tools="http://schemas.android.com/tools"> | |||||
| <manifest package="net.touchcapture.qr.flutterqr" | |||||
| xmlns:tools="http://schemas.android.com/tools"> | |||||
| <uses-sdk tools:overrideLibrary="com.google.zxing.client.android" /> | <uses-sdk tools:overrideLibrary="com.google.zxing.client.android" /> | ||||
| </manifest> | </manifest> | ||||
| @@ -1,50 +0,0 @@ | |||||
| package net.touchcapture.qr.flutterqr; | |||||
| import android.content.Context; | |||||
| import android.graphics.Rect; | |||||
| import android.util.AttributeSet; | |||||
| import com.journeyapps.barcodescanner.BarcodeView; | |||||
| import com.journeyapps.barcodescanner.Size; | |||||
| public class CustomFramingRectBarcodeView extends BarcodeView { | |||||
| private static final int BOTTOM_OFFSET_NOT_SET_VALUE = -1; | |||||
| private int bottomOffset = BOTTOM_OFFSET_NOT_SET_VALUE; | |||||
| public CustomFramingRectBarcodeView(Context context) { | |||||
| super(context); | |||||
| } | |||||
| public CustomFramingRectBarcodeView(Context context, AttributeSet attrs) { | |||||
| super(context, attrs); | |||||
| } | |||||
| public CustomFramingRectBarcodeView(Context context, AttributeSet attrs, int defStyleAttr) { | |||||
| super(context, attrs, defStyleAttr); | |||||
| } | |||||
| @Override | |||||
| protected Rect calculateFramingRect(Rect container, Rect surface) { | |||||
| Rect containerArea = new Rect(container); | |||||
| boolean intersects = containerArea.intersect(surface);//adjusts the containerArea (code from super.calculateFramingRect) | |||||
| Rect scanAreaRect = super.calculateFramingRect(container, surface); | |||||
| if (bottomOffset != BOTTOM_OFFSET_NOT_SET_VALUE) {//if the setFramingRect function was called, then we shift the scan area by Y | |||||
| Rect scanAreaRectWithOffset = new Rect(scanAreaRect); | |||||
| scanAreaRectWithOffset.bottom -= bottomOffset; | |||||
| scanAreaRectWithOffset.top -= bottomOffset; | |||||
| boolean belongsToContainer = scanAreaRectWithOffset.intersect(containerArea); | |||||
| if(belongsToContainer){ | |||||
| return scanAreaRectWithOffset; | |||||
| } | |||||
| } | |||||
| return scanAreaRect; | |||||
| } | |||||
| public void setFramingRect(int rectWidth, int rectHeight, int bottomOffset) { | |||||
| this.bottomOffset = bottomOffset; | |||||
| this.setFramingRectSize(new Size(rectWidth, rectHeight)); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,45 @@ | |||||
| package net.touchcapture.qr.flutterqr | |||||
| import android.content.Context | |||||
| import android.graphics.Rect | |||||
| import android.util.AttributeSet | |||||
| import com.journeyapps.barcodescanner.BarcodeView | |||||
| import com.journeyapps.barcodescanner.Size | |||||
| class CustomFramingRectBarcodeView : BarcodeView { | |||||
| private var bottomOffset = BOTTOM_OFFSET_NOT_SET_VALUE | |||||
| constructor(context: Context?) : super(context) {} | |||||
| constructor(context: Context?, attrs: AttributeSet?) : super(context, attrs) {} | |||||
| constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int) : super( | |||||
| context, | |||||
| attrs, | |||||
| defStyleAttr | |||||
| ) | |||||
| override fun calculateFramingRect(container: Rect, surface: Rect): Rect { | |||||
| val containerArea = Rect(container) | |||||
| val intersects = | |||||
| containerArea.intersect(surface) //adjusts the containerArea (code from super.calculateFramingRect) | |||||
| val scanAreaRect = super.calculateFramingRect(container, surface) | |||||
| if (bottomOffset != BOTTOM_OFFSET_NOT_SET_VALUE) { //if the setFramingRect function was called, then we shift the scan area by Y | |||||
| val scanAreaRectWithOffset = Rect(scanAreaRect) | |||||
| scanAreaRectWithOffset.bottom -= bottomOffset | |||||
| scanAreaRectWithOffset.top -= bottomOffset | |||||
| val belongsToContainer = scanAreaRectWithOffset.intersect(containerArea) | |||||
| if (belongsToContainer) { | |||||
| return scanAreaRectWithOffset | |||||
| } | |||||
| } | |||||
| return scanAreaRect | |||||
| } | |||||
| fun setFramingRect(rectWidth: Int, rectHeight: Int, bottomOffset: Int) { | |||||
| this.bottomOffset = bottomOffset | |||||
| framingRectSize = Size(rectWidth, rectHeight) | |||||
| } | |||||
| companion object { | |||||
| private const val BOTTOM_OFFSET_NOT_SET_VALUE = -1 | |||||
| } | |||||
| } | |||||
| @@ -1,65 +1,43 @@ | |||||
| package net.touchcapture.qr.flutterqr | package net.touchcapture.qr.flutterqr | ||||
| import android.app.Activity | |||||
| import android.content.pm.PackageManager | |||||
| import androidx.annotation.NonNull | import androidx.annotation.NonNull | ||||
| import io.flutter.embedding.engine.plugins.FlutterPlugin | import io.flutter.embedding.engine.plugins.FlutterPlugin | ||||
| import io.flutter.embedding.engine.plugins.activity.ActivityAware | import io.flutter.embedding.engine.plugins.activity.ActivityAware | ||||
| import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding | import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding | ||||
| import io.flutter.plugin.common.BinaryMessenger | |||||
| import io.flutter.plugin.common.PluginRegistry | |||||
| import io.flutter.plugin.platform.PlatformViewRegistry | |||||
| import net.touchcapture.qr.flutterqr.Shared.activity | |||||
| class FlutterQrPlugin : FlutterPlugin, ActivityAware { | class FlutterQrPlugin : FlutterPlugin, ActivityAware { | ||||
| /** Plugin registration embedding v1 */ | |||||
| companion object { | |||||
| @JvmStatic | |||||
| fun registerWith(registrar: PluginRegistry.Registrar) { | |||||
| FlutterQrPlugin().onAttachedToV1(registrar) | |||||
| } | |||||
| } | |||||
| private fun onAttachedToV1(registrar: PluginRegistry.Registrar) { | |||||
| Shared.registrar = registrar | |||||
| onAttachedToEngines(registrar.platformViewRegistry(), registrar.messenger(), registrar.activity()) | |||||
| } | |||||
| /** Plugin registration embedding v2 */ | /** Plugin registration embedding v2 */ | ||||
| override fun onAttachedToEngine(@NonNull flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) { | override fun onAttachedToEngine(@NonNull flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) { | ||||
| onAttachedToEngines(flutterPluginBinding.platformViewRegistry, flutterPluginBinding.binaryMessenger, Shared.activity) | |||||
| if (activity != null) { | |||||
| activity = activity | |||||
| } | |||||
| flutterPluginBinding.platformViewRegistry | |||||
| .registerViewFactory( | |||||
| "net.touchcapture.qr.flutterqr/qrview", QRViewFactory(flutterPluginBinding.binaryMessenger)) | |||||
| } | } | ||||
| override fun onDetachedFromEngine(binding: FlutterPlugin.FlutterPluginBinding) { | override fun onDetachedFromEngine(binding: FlutterPlugin.FlutterPluginBinding) { | ||||
| } | } | ||||
| /** Plugin start for both embedding v1 & v2 */ | |||||
| private fun onAttachedToEngines(platformViewRegistry: PlatformViewRegistry, messenger: BinaryMessenger, activity: Activity?) { | |||||
| if (activity != null) { | |||||
| Shared.activity = activity | |||||
| } | |||||
| platformViewRegistry | |||||
| .registerViewFactory( | |||||
| "net.touchcapture.qr.flutterqr/qrview", QRViewFactory(messenger)) | |||||
| } | |||||
| override fun onAttachedToActivity(activityPluginBinding: ActivityPluginBinding) { | override fun onAttachedToActivity(activityPluginBinding: ActivityPluginBinding) { | ||||
| Shared.activity = activityPluginBinding.activity | |||||
| activity = activityPluginBinding.activity | |||||
| Shared.binding = activityPluginBinding | Shared.binding = activityPluginBinding | ||||
| } | } | ||||
| override fun onDetachedFromActivityForConfigChanges() { | override fun onDetachedFromActivityForConfigChanges() { | ||||
| Shared.activity = null | |||||
| activity = null | |||||
| Shared.binding = null | Shared.binding = null | ||||
| } | } | ||||
| override fun onReattachedToActivityForConfigChanges(activityPluginBinding: ActivityPluginBinding) { | override fun onReattachedToActivityForConfigChanges(activityPluginBinding: ActivityPluginBinding) { | ||||
| Shared.activity = activityPluginBinding.activity | |||||
| activity = activityPluginBinding.activity | |||||
| Shared.binding = activityPluginBinding | Shared.binding = activityPluginBinding | ||||
| } | } | ||||
| override fun onDetachedFromActivity() { | override fun onDetachedFromActivity() { | ||||
| Shared.activity = null | |||||
| activity = null | |||||
| Shared.binding = null | Shared.binding = null | ||||
| } | } | ||||
| @@ -34,10 +34,6 @@ class QRView(private val context: Context, messenger: BinaryMessenger, private v | |||||
| Shared.binding!!.addRequestPermissionsResultListener(this) | Shared.binding!!.addRequestPermissionsResultListener(this) | ||||
| } | } | ||||
| if (Shared.registrar != null) { | |||||
| Shared.registrar!!.addRequestPermissionsResultListener(this) | |||||
| } | |||||
| channel.setMethodCallHandler(this) | channel.setMethodCallHandler(this) | ||||
| Shared.activity?.application?.registerActivityLifecycleCallbacks(object : Application.ActivityLifecycleCallbacks { | Shared.activity?.application?.registerActivityLifecycleCallbacks(object : Application.ActivityLifecycleCallbacks { | ||||
| override fun onActivityPaused(p0: Activity) { | override fun onActivityPaused(p0: Activity) { | ||||
| @@ -306,14 +302,14 @@ class QRView(private val context: Context, messenger: BinaryMessenger, private v | |||||
| permissions: Array<out String>?, | permissions: Array<out String>?, | ||||
| grantResults: IntArray): Boolean { | grantResults: IntArray): Boolean { | ||||
| if(requestCode == Shared.CAMERA_REQUEST_ID + this.id) { | if(requestCode == Shared.CAMERA_REQUEST_ID + this.id) { | ||||
| if (grantResults.isNotEmpty() && grantResults[0] == PackageManager.PERMISSION_GRANTED) { | |||||
| return if (grantResults.isNotEmpty() && grantResults[0] == PackageManager.PERMISSION_GRANTED) { | |||||
| permissionGranted = true | permissionGranted = true | ||||
| channel.invokeMethod("onPermissionSet", true) | channel.invokeMethod("onPermissionSet", true) | ||||
| return true | |||||
| true | |||||
| } else { | } else { | ||||
| permissionGranted = false | permissionGranted = false | ||||
| channel.invokeMethod("onPermissionSet", false) | channel.invokeMethod("onPermissionSet", false) | ||||
| return false | |||||
| false | |||||
| } | } | ||||
| } | } | ||||
| return false | return false | ||||
| @@ -8,5 +8,4 @@ object Shared { | |||||
| const val CAMERA_REQUEST_ID = 513469796 | const val CAMERA_REQUEST_ID = 513469796 | ||||
| var activity: Activity? = null | var activity: Activity? = null | ||||
| var binding: ActivityPluginBinding? = null | var binding: ActivityPluginBinding? = null | ||||
| var registrar: PluginRegistry.Registrar? = null | |||||
| } | } | ||||
| @@ -0,0 +1 @@ | |||||
| include: package:flutter_lints/flutter.yaml | |||||
| @@ -26,7 +26,7 @@ apply plugin: 'kotlin-android' | |||||
| apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" | apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" | ||||
| android { | android { | ||||
| compileSdkVersion 30 | |||||
| compileSdkVersion 31 | |||||
| sourceSets { | sourceSets { | ||||
| main.java.srcDirs += 'src/main/kotlin' | main.java.srcDirs += 'src/main/kotlin' | ||||
| @@ -36,7 +36,7 @@ android { | |||||
| applicationId "net.touchcapture.qr.flutterqrexample" | applicationId "net.touchcapture.qr.flutterqrexample" | ||||
| // minSdkVersion is determined by Native View. | // minSdkVersion is determined by Native View. | ||||
| minSdkVersion 20 | minSdkVersion 20 | ||||
| targetSdkVersion 30 | |||||
| targetSdkVersion 31 | |||||
| versionCode flutterVersionCode.toInteger() | versionCode flutterVersionCode.toInteger() | ||||
| versionName flutterVersionName | versionName flutterVersionName | ||||
| testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" | ||||
| @@ -56,7 +56,7 @@ flutter { | |||||
| dependencies { | dependencies { | ||||
| implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" | ||||
| testImplementation 'junit:junit:4.13.1' | |||||
| testImplementation 'junit:junit:4.13.2' | |||||
| androidTestImplementation 'com.android.support.test:runner:1.0.2' | androidTestImplementation 'com.android.support.test:runner:1.0.2' | ||||
| androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' | ||||
| } | } | ||||
| @@ -16,17 +16,13 @@ | |||||
| android:label="flutter_qr_example" | android:label="flutter_qr_example" | ||||
| android:icon="@mipmap/ic_launcher"> | android:icon="@mipmap/ic_launcher"> | ||||
| <activity | <activity | ||||
| android:name=".MainActivity" | |||||
| android:name="io.flutter.embedding.android.FlutterActivity" | |||||
| android:launchMode="singleTop" | android:launchMode="singleTop" | ||||
| android:theme="@style/LaunchTheme" | android:theme="@style/LaunchTheme" | ||||
| android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density" | android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density" | ||||
| android:hardwareAccelerated="true" | android:hardwareAccelerated="true" | ||||
| android:exported='true' | |||||
| android:windowSoftInputMode="adjustResize"> | android:windowSoftInputMode="adjustResize"> | ||||
| <!-- Specify that the launch screen should continue being displayed --> | |||||
| <!-- until Flutter renders its first frame. --> | |||||
| <meta-data | |||||
| android:name="io.flutter.embedding.android.SplashScreenDrawable" | |||||
| android:resource="@drawable/launch_background" /> | |||||
| <!-- Theme to apply as soon as Flutter begins rendering frames --> | <!-- Theme to apply as soon as Flutter begins rendering frames --> | ||||
| <meta-data | <meta-data | ||||
| android:name="io.flutter.embedding.android.NormalTheme" | android:name="io.flutter.embedding.android.NormalTheme" | ||||
| @@ -1,6 +0,0 @@ | |||||
| package net.touchcapture.qr.flutterqrexample | |||||
| import io.flutter.embedding.android.FlutterActivity | |||||
| class MainActivity: FlutterActivity() { | |||||
| } | |||||
| @@ -1,12 +1,12 @@ | |||||
| buildscript { | buildscript { | ||||
| ext.kotlin_version = '1.5.10' | |||||
| ext.kotlin_version = '1.5.31' | |||||
| repositories { | repositories { | ||||
| google() | google() | ||||
| mavenCentral() | mavenCentral() | ||||
| } | } | ||||
| dependencies { | dependencies { | ||||
| classpath 'com.android.tools.build:gradle:4.2.1' | |||||
| classpath 'com.android.tools.build:gradle:7.0.2' | |||||
| classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" | ||||
| } | } | ||||
| } | } | ||||
| @@ -1,6 +1,6 @@ | |||||
| #Thu Dec 10 21:49:57 CET 2020 | |||||
| #Fri Oct 08 10:14:36 CEST 2021 | |||||
| distributionBase=GRADLE_USER_HOME | distributionBase=GRADLE_USER_HOME | ||||
| distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip | |||||
| distributionPath=wrapper/dists | distributionPath=wrapper/dists | ||||
| zipStoreBase=GRADLE_USER_HOME | |||||
| zipStorePath=wrapper/dists | zipStorePath=wrapper/dists | ||||
| distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-all.zip | |||||
| zipStoreBase=GRADLE_USER_HOME | |||||
| @@ -5,7 +5,7 @@ import 'package:flutter/foundation.dart'; | |||||
| import 'package:flutter/material.dart'; | import 'package:flutter/material.dart'; | ||||
| import 'package:qr_code_scanner/qr_code_scanner.dart'; | import 'package:qr_code_scanner/qr_code_scanner.dart'; | ||||
| void main() => runApp(MaterialApp(home: MyHome())); | |||||
| void main() => runApp(const MaterialApp(home: MyHome())); | |||||
| class MyHome extends StatelessWidget { | class MyHome extends StatelessWidget { | ||||
| const MyHome({Key? key}) : super(key: key); | const MyHome({Key? key}) : super(key: key); | ||||
| @@ -13,15 +13,15 @@ class MyHome extends StatelessWidget { | |||||
| @override | @override | ||||
| Widget build(BuildContext context) { | Widget build(BuildContext context) { | ||||
| return Scaffold( | return Scaffold( | ||||
| appBar: AppBar(title: Text('Flutter Demo Home Page')), | |||||
| appBar: AppBar(title: const Text('Flutter Demo Home Page')), | |||||
| body: Center( | body: Center( | ||||
| child: ElevatedButton( | child: ElevatedButton( | ||||
| onPressed: () { | onPressed: () { | ||||
| Navigator.of(context).push(MaterialPageRoute( | Navigator.of(context).push(MaterialPageRoute( | ||||
| builder: (context) => QRViewExample(), | |||||
| builder: (context) => const QRViewExample(), | |||||
| )); | )); | ||||
| }, | }, | ||||
| child: Text('qrView'), | |||||
| child: const Text('qrView'), | |||||
| ), | ), | ||||
| ), | ), | ||||
| ); | ); | ||||
| @@ -29,6 +29,8 @@ class MyHome extends StatelessWidget { | |||||
| } | } | ||||
| class QRViewExample extends StatefulWidget { | class QRViewExample extends StatefulWidget { | ||||
| const QRViewExample({Key? key}) : super(key: key); | |||||
| @override | @override | ||||
| State<StatefulWidget> createState() => _QRViewExampleState(); | State<StatefulWidget> createState() => _QRViewExampleState(); | ||||
| } | } | ||||
| @@ -66,13 +68,13 @@ class _QRViewExampleState extends State<QRViewExample> { | |||||
| Text( | Text( | ||||
| 'Barcode Type: ${describeEnum(result!.format)} Data: ${result!.code}') | 'Barcode Type: ${describeEnum(result!.format)} Data: ${result!.code}') | ||||
| else | else | ||||
| Text('Scan a code'), | |||||
| const Text('Scan a code'), | |||||
| Row( | Row( | ||||
| mainAxisAlignment: MainAxisAlignment.center, | mainAxisAlignment: MainAxisAlignment.center, | ||||
| crossAxisAlignment: CrossAxisAlignment.center, | crossAxisAlignment: CrossAxisAlignment.center, | ||||
| children: <Widget>[ | children: <Widget>[ | ||||
| Container( | Container( | ||||
| margin: EdgeInsets.all(8), | |||||
| margin: const EdgeInsets.all(8), | |||||
| child: ElevatedButton( | child: ElevatedButton( | ||||
| onPressed: () async { | onPressed: () async { | ||||
| await controller?.toggleFlash(); | await controller?.toggleFlash(); | ||||
| @@ -86,7 +88,7 @@ class _QRViewExampleState extends State<QRViewExample> { | |||||
| )), | )), | ||||
| ), | ), | ||||
| Container( | Container( | ||||
| margin: EdgeInsets.all(8), | |||||
| margin: const EdgeInsets.all(8), | |||||
| child: ElevatedButton( | child: ElevatedButton( | ||||
| onPressed: () async { | onPressed: () async { | ||||
| await controller?.flipCamera(); | await controller?.flipCamera(); | ||||
| @@ -99,7 +101,7 @@ class _QRViewExampleState extends State<QRViewExample> { | |||||
| return Text( | return Text( | ||||
| 'Camera facing ${describeEnum(snapshot.data!)}'); | 'Camera facing ${describeEnum(snapshot.data!)}'); | ||||
| } else { | } else { | ||||
| return Text('loading'); | |||||
| return const Text('loading'); | |||||
| } | } | ||||
| }, | }, | ||||
| )), | )), | ||||
| @@ -111,21 +113,23 @@ class _QRViewExampleState extends State<QRViewExample> { | |||||
| crossAxisAlignment: CrossAxisAlignment.center, | crossAxisAlignment: CrossAxisAlignment.center, | ||||
| children: <Widget>[ | children: <Widget>[ | ||||
| Container( | Container( | ||||
| margin: EdgeInsets.all(8), | |||||
| margin: const EdgeInsets.all(8), | |||||
| child: ElevatedButton( | child: ElevatedButton( | ||||
| onPressed: () async { | onPressed: () async { | ||||
| await controller?.pauseCamera(); | await controller?.pauseCamera(); | ||||
| }, | }, | ||||
| child: Text('pause', style: TextStyle(fontSize: 20)), | |||||
| child: const Text('pause', | |||||
| style: TextStyle(fontSize: 20)), | |||||
| ), | ), | ||||
| ), | ), | ||||
| Container( | Container( | ||||
| margin: EdgeInsets.all(8), | |||||
| margin: const EdgeInsets.all(8), | |||||
| child: ElevatedButton( | child: ElevatedButton( | ||||
| onPressed: () async { | onPressed: () async { | ||||
| await controller?.resumeCamera(); | await controller?.resumeCamera(); | ||||
| }, | }, | ||||
| child: Text('resume', style: TextStyle(fontSize: 20)), | |||||
| child: const Text('resume', | |||||
| style: TextStyle(fontSize: 20)), | |||||
| ), | ), | ||||
| ) | ) | ||||
| ], | ], | ||||
| @@ -175,7 +179,7 @@ class _QRViewExampleState extends State<QRViewExample> { | |||||
| log('${DateTime.now().toIso8601String()}_onPermissionSet $p'); | log('${DateTime.now().toIso8601String()}_onPermissionSet $p'); | ||||
| if (!p) { | if (!p) { | ||||
| ScaffoldMessenger.of(context).showSnackBar( | ScaffoldMessenger.of(context).showSnackBar( | ||||
| SnackBar(content: Text('no Permission')), | |||||
| const SnackBar(content: Text('no Permission')), | |||||
| ); | ); | ||||
| } | } | ||||
| } | } | ||||
| @@ -10,7 +10,7 @@ dependencies: | |||||
| sdk: flutter | sdk: flutter | ||||
| dev_dependencies: | dev_dependencies: | ||||
| pedantic: ^1.11.0 | |||||
| flutter_lints: ^1.0.4 | |||||
| flutter_test: | flutter_test: | ||||
| sdk: flutter | sdk: flutter | ||||
| @@ -126,7 +126,7 @@ class _QRViewState extends State<QRView> { | |||||
| onPlatformViewCreated: _onPlatformViewCreated, | onPlatformViewCreated: _onPlatformViewCreated, | ||||
| creationParams: | creationParams: | ||||
| _QrCameraSettings(cameraFacing: widget.cameraFacing).toMap(), | _QrCameraSettings(cameraFacing: widget.cameraFacing).toMap(), | ||||
| creationParamsCodec: StandardMessageCodec(), | |||||
| creationParamsCodec: const StandardMessageCodec(), | |||||
| ); | ); | ||||
| break; | break; | ||||
| case TargetPlatform.iOS: | case TargetPlatform.iOS: | ||||
| @@ -135,7 +135,7 @@ class _QRViewState extends State<QRView> { | |||||
| onPlatformViewCreated: _onPlatformViewCreated, | onPlatformViewCreated: _onPlatformViewCreated, | ||||
| creationParams: | creationParams: | ||||
| _QrCameraSettings(cameraFacing: widget.cameraFacing).toMap(), | _QrCameraSettings(cameraFacing: widget.cameraFacing).toMap(), | ||||
| creationParamsCodec: StandardMessageCodec(), | |||||
| creationParamsCodec: const StandardMessageCodec(), | |||||
| ); | ); | ||||
| break; | break; | ||||
| default: | default: | ||||
| @@ -327,7 +327,7 @@ class QRViewController { | |||||
| {QrScannerOverlayShape? overlay}) async { | {QrScannerOverlayShape? overlay}) async { | ||||
| if (defaultTargetPlatform == TargetPlatform.iOS) { | if (defaultTargetPlatform == TargetPlatform.iOS) { | ||||
| // Add small delay to ensure the render box is loaded | // Add small delay to ensure the render box is loaded | ||||
| await Future.delayed(Duration(milliseconds: 300)); | |||||
| await Future.delayed(const Duration(milliseconds: 300)); | |||||
| if (key.currentContext == null) return false; | if (key.currentContext == null) return false; | ||||
| final renderBox = key.currentContext!.findRenderObject() as RenderBox; | final renderBox = key.currentContext!.findRenderObject() as RenderBox; | ||||
| try { | try { | ||||
| @@ -1,3 +1,5 @@ | |||||
| // ignore_for_file: avoid_web_libraries_in_flutter | |||||
| import 'dart:async'; | import 'dart:async'; | ||||
| import 'dart:core'; | import 'dart:core'; | ||||
| import 'dart:html' as html; | import 'dart:html' as html; | ||||
| @@ -59,11 +61,11 @@ class _WebQrViewState extends State<WebQrView> { | |||||
| QRViewControllerWeb? _controller; | QRViewControllerWeb? _controller; | ||||
| late Size _size = Size(0, 0); | |||||
| late Size _size = const Size(0, 0); | |||||
| Timer? timer; | Timer? timer; | ||||
| String? code; | String? code; | ||||
| String? _errorMsg; | String? _errorMsg; | ||||
| var video; | |||||
| html.VideoElement video = html.VideoElement(); | |||||
| String viewID = 'QRVIEW-' + DateTime.now().millisecondsSinceEpoch.toString(); | String viewID = 'QRVIEW-' + DateTime.now().millisecondsSinceEpoch.toString(); | ||||
| final StreamController<Barcode> _scanUpdateController = | final StreamController<Barcode> _scanUpdateController = | ||||
| @@ -78,13 +80,13 @@ class _WebQrViewState extends State<WebQrView> { | |||||
| facing = widget.cameraFacing ?? CameraFacing.front; | facing = widget.cameraFacing ?? CameraFacing.front; | ||||
| video = html.VideoElement(); | |||||
| // video = html.VideoElement(); | |||||
| WebQrView.vidDiv.children = [video]; | WebQrView.vidDiv.children = [video]; | ||||
| // ignore: UNDEFINED_PREFIXED_NAME | // ignore: UNDEFINED_PREFIXED_NAME | ||||
| ui.platformViewRegistry | ui.platformViewRegistry | ||||
| .registerViewFactory(viewID, (int id) => WebQrView.vidDiv); | .registerViewFactory(viewID, (int id) => WebQrView.vidDiv); | ||||
| // giving JavaScipt some time to process the DOM changes | // giving JavaScipt some time to process the DOM changes | ||||
| Timer(Duration(milliseconds: 500), () { | |||||
| Timer(const Duration(milliseconds: 500), () { | |||||
| start(); | start(); | ||||
| }); | }); | ||||
| } | } | ||||
| @@ -92,7 +94,8 @@ class _WebQrViewState extends State<WebQrView> { | |||||
| Future start() async { | Future start() async { | ||||
| await _makeCall(); | await _makeCall(); | ||||
| _frameIntervall?.cancel(); | _frameIntervall?.cancel(); | ||||
| _frameIntervall = Timer.periodic(Duration(milliseconds: 200), (timer) { | |||||
| _frameIntervall = | |||||
| Timer.periodic(const Duration(milliseconds: 200), (timer) { | |||||
| _captureFrame2(); | _captureFrame2(); | ||||
| }); | }); | ||||
| } | } | ||||
| @@ -202,7 +205,7 @@ class _WebQrViewState extends State<WebQrView> { | |||||
| return Center(child: Text(_errorMsg!)); | return Center(child: Text(_errorMsg!)); | ||||
| } | } | ||||
| if (_localStream == null) { | if (_localStream == null) { | ||||
| return Center(child: CircularProgressIndicator()); | |||||
| return const Center(child: CircularProgressIndicator()); | |||||
| } | } | ||||
| return LayoutBuilder( | return LayoutBuilder( | ||||
| builder: (context, constraints) { | builder: (context, constraints) { | ||||
| @@ -6,7 +6,7 @@ repository: https://github.com/juliuscanute/qr_code_scanner | |||||
| environment: | environment: | ||||
| sdk: '>=2.12.0 <3.0.0' | sdk: '>=2.12.0 <3.0.0' | ||||
| flutter: ">=1.10.0" | |||||
| flutter: ">=1.12.0" | |||||
| dependencies: | dependencies: | ||||
| js: ^0.6.3 | js: ^0.6.3 | ||||
| @@ -16,7 +16,7 @@ dependencies: | |||||
| sdk: flutter | sdk: flutter | ||||
| dev_dependencies: | dev_dependencies: | ||||
| pedantic: ^1.11.0 | |||||
| flutter_lints: ^1.0.4 | |||||
| flutter: | flutter: | ||||
| plugin: | plugin: | ||||