i'm running a flutter project but i'm facing many problems so this are the versions : flutter :3.0.1 Dart:2.17 . This is the error i have :
../flutter/.pub-cache/hosted/pub.dartlang.org/flutter_swipe_action_cell-2.2.1/lib/core/swipe_pull_button.dart:68:20: Warning: Operand of null-aware operation '!' has type 'WidgetsBinding' which excludes null.
- 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart' ('../flutter/packages/flutter/lib/src/widgets/binding.dart').
WidgetsBinding.instance!.addPostFrameCallback((timeStamp) {
^
e: /home/imen/flutter/.pub-cache/hosted/pub.dartlang.org/barcode_scan2-4.2.0/android/src/main/kotlin/de/mintware/barcode_scan/ActivityHelper.kt: (16, 1): Class 'ActivityHelper' is not abstract and does not implement abstract member public abstract fun onRequestPermissionsResult(p0: Int, p1: Array<(out) String!>, p2: IntArray): Boolean defined in io.flutter.plugin.common.PluginRegistry.RequestPermissionsResultListener
e: /home/imen/flutter/.pub-cache/hosted/pub.dartlang.org/barcode_scan2-4.2.0/android/src/main/kotlin/de/mintware/barcode_scan/ActivityHelper.kt: (71, 5): 'onRequestPermissionsResult' overrides nothing
e: /home/imen/flutter/.pub-cache/hosted/pub.dartlang.org/barcode_scan2-4.2.0/android/src/main/kotlin/de/mintware/barcode_scan/ActivityHelper.kt: (81, 58): Type mismatch: inferred type is Array<CapturedType(out String)>? but Array<(out) String!> was expected
e: /home/imen/flutter/.pub-cache/hosted/pub.dartlang.org/barcode_scan2-4.2.0/android/src/main/kotlin/de/mintware/barcode_scan/ActivityHelper.kt: (81, 71): Type mismatch: inferred type is IntArray? but IntArray was expected
e: /home/imen/flutter/.pub-cache/hosted/pub.dartlang.org/barcode_scan2-4.2.0/android/src/main/kotlin/de/mintware/barcode_scan/ChannelHandler.kt: (64, 39): Type mismatch: inferred type is BinaryMessenger? but BinaryMessenger was expected
e: /home/imen/flutter/.pub-cache/hosted/pub.dartlang.org/barcode_scan2-4.2.0/android/src/main/kotlin/de/mintware/barcode_scan/RequestCameraPermissionHandler.kt: (8, 1): Class 'RequestCameraPermissionHandler' is not abstract and does not implement abstract member public abstract fun onRequestPermissionsResult(p0: Int, p1: Array<(out) String!>, p2: IntArray): Boolean defined in io.flutter.plugin.common.PluginRegistry.RequestPermissionsResultListener
e: /home/imen/flutter/.pub-cache/hosted/pub.dartlang.org/barcode_scan2-4.2.0/android/src/main/kotlin/de/mintware/barcode_scan/RequestCameraPermissionHandler.kt: (11, 5): 'onRequestPermissionsResult' overrides nothing
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':barcode_scan2:compileDebugKotlin'.
> Compilation error. See log for more details
i don't have a problem in the installation of flutter while running flutter doctor it shows that every thing is well installed
CodePudding user response:
in the plugin documentation: https://pub.dev/packages/barcode_scan2. your kotlin version needs to be:
kotlin version '1.3.61
Go to your build.gradle file in the root of your Android directory and change your Kotlin_version
This plugin is written in Kotlin. Therefore, you need to add Kotlin support to your project. follow this stackoverflow answer: How to add Kotlin support to your flutter project?
make sure to add the camera permission to your AndroidManifest.xml
<uses-permission android:name="android.permission.CAMERA" />
now it should work.
CodePudding user response:
Check if you are using the latest kotlin version that matches your current flutter version. In your android directory in build.gradle:
ext.kotlin_version = '1.5.31'
If that does not fix the error, just delete android/.gradle
then run the app in debug.