deadblit / barras Goto Github PK
View Code? Open in Web Editor NEWA simple and customizable barcode scanning Flutter package for Android and iOS. It uses AVCaptureSession in iOS and ZXing in Android.
License: MIT License
A simple and customizable barcode scanning Flutter package for Android and iOS. It uses AVCaptureSession in iOS and ZXing in Android.
License: MIT License
======== Exception caught by widgets library =======================================================
The following NoSuchMethodError was thrown while finalizing the widget tree:
The method 'cancel' was called on null.
Receiver: null
Tried calling: cancel()
Hello,
Thank you for the nice package.
I've been playing around with it, and it was working fine. But after upgrading to new flutter.
The package throws exception when building the project. Execution failed for task ':qrcode:compileDebugKotlin'.
@deadblitPub Dependencies
environment:
sdk: ">=2.7.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^1.0.1
google_fonts: ^1.1.1
firebase_messaging: ^7.0.3
overlay_support: ^1.0.5
url_launcher: ^5.7.10
flutter_local_notifications: ^3.0.2
webview_flutter: ^1.0.7
http: ^0.12.2
shared_preferences: ^0.5.12+4
barras: ^0.0.2
dev_dependencies:
flutter_test:
sdk: flutter
integration_test:
sdk: flutter
`
android/build.gradle [project root]
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.android.tools.build:gradle:4.1.0'
// Add the google services classpath
classpath 'com.google.gms:google-services:4.3.2'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
`
android/app/build.gradle
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}
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 from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
lintOptions {
abortOnError false
checkReleaseBuilds false //<- add this line
}
compileSdkVersion 30
defaultConfig {
multiDexEnabled true
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.mangowi.mpwa"
minSdkVersion 23
targetSdkVersion 30
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
signingConfigs {
release {
}
}
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.release
}
}
flavorDimensions "flavors"
// product flavors
productFlavors{
demomain{
dimension "flavors"
applicationIdSuffix ".app.mainflavor"
versionCode 6
versionName "1.0.0"
}
demohumle{
dimension "flavors"
applicationIdSuffix ".app.secondflavor"
versionCode 6
versionName "1.0.0"
}
}
}
dependencies{
implementation 'com.android.support:multidex:1.0.3'
}
flutter {
source '../..'
}
apply plugin: 'com.google.gms.google-services'
`
I'm having a BarCode scanner and a TextFormField.
When presssed on the BarCode scanner it scans perfectly and retreives the BarCode and prints it in the TextFormField.
But when you enter your custom text in the TextFormField and press the BarCode scanner a black screen cones inside the scanner but retreives some odd Barcode value.
TextEditingController someController = TextEditingController();
String _scannedCode = "";
scanBarCode() async {
final data = await Barras.scan(
context,
viewfinderHeight: 120,
viewfinderWidth: 300,
scrimColor: Color.fromRGBO(128, 0, 0, 0.5),
borderColor: Colors.red,
borderRadius: 24,
borderStrokeWidth: 2,
buttonColor: Colors.yellow,
borderFlashDuration: 250,
cancelButtonText: "Cancel",
successBeep: false,
);
setState(() {
_scannedCode = data ?? "";
print(data);
print(_scannedCode);
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
actions: [
IconButton(
icon: Icon(Icons.scanner),
onPressed: scanBarCode),
SizedBox(
width: 20,
),
],
),
body: Padding(
padding: const EdgeInsets.all(20.0),
child: Column(
children: [
_scannedCode.isEmpty ? TextFormField(
style: TextStyle(color: Colors.blueGrey),
controller: someController,
textCapitalization: TextCapitalization.characters,
decoration: InputDecoration(
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(color: Colors.blueGrey),
),
prefixIcon: Icon(
Icons.scanner,
color: Colors.blueGrey,
),
suffixIcon: IconButton(
icon: Icon(
Icons.clear,
color: Colors.blueGrey,
),
onPressed: () {
someController.clear();
},
),
labelStyle: TextStyle(color: Color(0xFFCFB53B)),
labelText: 'Article Number',
contentPadding: EdgeInsets.all(15.0),
isDense: true,
border: OutlineInputBorder(borderSide: BorderSide(color: Colors.blueGrey)),
focusedBorder: OutlineInputBorder(borderSide: BorderSide(color: Colors.blueGrey))),
) : TextFormField(
style: TextStyle(color: Colors.blueGrey),
controller: someController..text = _scannedCode,
textCapitalization: TextCapitalization.characters,
decoration: InputDecoration(
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(color: Colors.blueGrey),
),
prefixIcon: Icon(
Icons.scanner,
color: Colors.blueGrey,
),
suffixIcon: IconButton(
icon: Icon(
Icons.clear,
color: Colors.blueGrey,
),
onPressed: () {
someController.clear();
},
),
labelStyle: TextStyle(color: Color(0xFFCFB53B)),
labelText: 'Article Number',
contentPadding: EdgeInsets.all(15.0),
isDense: true,
border: OutlineInputBorder(borderSide: BorderSide(color: Colors.blueGrey)),
focusedBorder: OutlineInputBorder(borderSide: BorderSide(color: Colors.blueGrey))),
),
Padding(
padding: const EdgeInsets.symmetric(vertical: 16.0),
child: ElevatedButton(
onPressed: () {
scanBarCode();
},
child: Text('Scan'),
),
),
],
),
),
);
}
I can't even run the app, it's giving me this error with the qrcode library... (even that I want to use just the barcode function)
e: C:\Program Files\flutter\.pub-cache\hosted\pub.dartlang.org\qrcode-1.0.4\android\src\main\kotlin\com\example\qrcode\QRCaptureView.kt: (126, 10): Object is not abstract and does not implement abstract member public abstract fun onActivityPaused(@NonNull p0: Activity): Unit defined in android.app.Application.ActivityLifecycleCallbacks
e: C:\Program Files\flutter\.pub-cache\hosted\pub.dartlang.org\qrcode-1.0.4\android\src\main\kotlin\com\example\qrcode\QRCaptureView.kt: (127, 14): 'onActivityPaused' overrides nothing
e: C:\Program Files\flutter\.pub-cache\hosted\pub.dartlang.org\qrcode-1.0.4\android\src\main\kotlin\com\example\qrcode\QRCaptureView.kt: (133, 14): 'onActivityResumed' overrides nothing
e: C:\Program Files\flutter\.pub-cache\hosted\pub.dartlang.org\qrcode-1.0.4\android\src\main\kotlin\com\example\qrcode\QRCaptureView.kt: (139, 14): 'onActivityStarted' overrides nothing
e: C:\Program Files\flutter\.pub-cache\hosted\pub.dartlang.org\qrcode-1.0.4\android\src\main\kotlin\com\example\qrcode\QRCaptureView.kt: (142, 14): 'onActivityDestroyed' overrides nothing
e: C:\Program Files\flutter\.pub-cache\hosted\pub.dartlang.org\qrcode-1.0.4\android\src\main\kotlin\com\example\qrcode\QRCaptureView.kt: (145, 14): 'onActivitySaveInstanceState' overrides nothing
e: C:\Program Files\flutter\.pub-cache\hosted\pub.dartlang.org\qrcode-1.0.4\android\src\main\kotlin\com\example\qrcode\QRCaptureView.kt: (148, 14): 'onActivityStopped' overrides nothing
e: C:\Program Files\flutter\.pub-cache\hosted\pub.dartlang.org\qrcode-1.0.4\android\src\main\kotlin\com\example\qrcode\QRCaptureView.kt: (151, 14): 'onActivityCreated' overrides nothing
FAILURE: Build failed with an exception.
Feel free to ask me any question so we can solve this issue together (Brasileiro aqui tambem... so escrevi em ingles para see algum extrangeiro tiver alguma ideia de como resolver)
Parabens pelo trabalho incrivel!
Really thankful for the package
But to use this with the latest version of flutter with sound null safety, a problem occurs.
As most of the packages are migrated to null safety, this too needs an update.
Olá!!
Você pode realizar várias digitalizações sem fechar o scanner?
Obrigado
Muito boa essa lib.
Funcionou muito bem quase todas as vezes que testei. Mas as vezes a tela de escanear fica preta.
Mesmo com a tela preta ele consegue detectar o código de barras.
flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel beta, 1.24.0-10.2.pre, on Mac OS X 10.15.2 19C57 darwin-x64, locale pt-BR)
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
[✓] Xcode - develop for iOS and macOS (Xcode 11.2.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 4.0)
[✓] VS Code (version 1.51.1)
[✓] Connected device (2 available)
• No issues found!
Could you, please, add some validation?
Would be great to pass the function that return true if barcode is valid (scanned item is exists in database, for example) or false if not and scan in infinity loop until this function return true or cancel pressed. Maybe it's reasonable to pass callback for failed scan - developers could show a Toast in that case or play custom sound
Hi! Try to add barras dependency as:
barras:
git:
url: https://github.com/deadblit/barras.git
ref: r0.1.0-nullsafety.2
However, got an error when trying to lunch the app
The plugins qrcode, torch_compat
use a deprecated version of the Android embedding.
To avoid unexpected runtime failures, or future build failures, try to see if these plugins support the Android V2 embedding. Otherwise, consider removing them since a future release of Flutter will remove these deprecated APIs.
Not able to open scanner in MI Note 5 Pro. Instead of scanner it's showing complete back screen. Any solution for this error- Access denied finding property "vendor.camera.aux.packagelist"
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.