Flutter demo app showcases Barkoder's barcode scanner, featuring a full suite of barcode scanning capabilities with customizable template settings
Flutter is Google's SDK for crafting beautiful, fast user experiences for mobile, web, and desktop from a single codebase. Flutter works with existing code, is used by developers and organizations around the world, and is free and open source.
Choose a text editor or integrated development environment (IDE) for coding. Recommended options include:
Install Git for version control and project management. Git will help you track changes and collaborate with others on the project.
Ensure you have a command line interface (CLI) installed and accessible, as Cordova commands are executed via the command line. Popular options include:
- Terminal (macOS/Linux)
- Command Prompt (Windows)
- PowerShell (Windows)
iOS Development: Install Xcode (macOS only) for iOS development. Xcode provides the necessary tools and emulators for testing your app on iOS devices.
Android Development: Install Android Studio for Android development. Android Studio includes the Android SDK and an emulator for testing your app on Android devices.
Depending on the platform you plan to use, this will be different for your use-case, however, flutter covers all major platforms and the installation is pretty straight forward.
Install Flutter SDK and follow the Set up an editor instructions to install the Dart and Flutter extensions (also called plugins).
To create a new Flutter project from the Flutter starter app template:
- Go to
View
>Command Palette...
(You can also pressCtrl
/Cmd
+Shift
+P
) - Type
flutter
. - Select the Flutter: New Project.
- Press
Enter
. - Select Application.
- Press
Enter
. - Select a Project location.
- Enter your desired Project name.
Integrating the barKoder SDK with the Flutter platform is a straightforward and seamless process, designed to empower developers with powerful barcode scanning capabilities in their cross-platform mobile applications. To begin, simply add the barKoder SDK as a dependency in your Flutter project's pubspec.yaml file. Once the dependency is added, developers can access a range of easy-to-use widgets and APIs offered by the SDK. To implement barcode scanning functionalities, developers can utilize the BarkoderScanView widget, which provides a native camera view for scanning barcodes. With just a few lines of code, you can configure the widget to enable different barcode types, customize UI elements, and set scanning options to suit your specific application requirements. The SDK efficiently handles barcode recognition, instantly returning accurate results upon successful scans.
Whether you're building an inventory management app or a retail application, the barKoder SDK integration with Flutter streamlines the process, enabling you to create a seamless and native-feeling barcode scanning experience for both Android and iOS users.
There are multiple ways to add the barkoder_flutter package to your Flutter project (or we should say, at least for now, two ways):
- To use the barkoder_flutter package in your Flutter project, you have two options: using the barkoder_flutter package from pub.dev;
- Referencing it from a local path.
To use the package from pub.dev, add the package name and version to your project's dependencies:
dependencies:
flutter:
sdk: flutter
barkoder_flutter: <package version>
If you prefer to use a local package, download the package from https://barkoder.com and set the package path in your project's dependencies:
dependencies:
flutter:
sdk: flutter
barkoder_flutter:
path: <package local path>
To install the specified dependencies in your Flutter project, run the following command in the terminal:
flutter pub get
This command will fetch and install the required dependencies for your project.
In the demo app we also used the following dependencies:
url_launcher: ^6.1.8
shared_preferences: ^2.0.0
share_plus: ^10.0.0
cupertino_icons: ^1.0.6
Import the barkoder_flutter package in your project with:
import 'package:barkoder_flutter/barkoder_flutter.dart';
At this stage, assuming that the barkoder_flutter package is installed and imported into your project, you can proceed to add the BarkoderView widget to your layout. Make sure to set the licenseKey parameter and the onBarkoderViewCreated callback. Here's an example of how to accomplish this:
@override
Widget build(BuildContext context) {
return Scaffold(
//...,
body: BarkoderView(
licenseKey: 'KEY',
onBarkoderViewCreated: _onBarkoderViewCreated),
//...
);
The license key is a string composed of alphanumeric characters, meaning it can contain both letters (A-Z, a-z) and numbers (0-9). See section Licensing to learn how to get a valid license.
Inside the _onBarkoderViewCreated callback function the SDK is fully initialized and ready for configuration or to start the scanning process
void _onBarkoderViewCreated(barkoder) {
_barkoder = barkoder;
_barkoder.setBarcodeTypeEnabled(BarcodeType.qr, true);
_barkoder.setRegionOfInterestVisible(true);
//... add other code here
}
void _scanPressed() {
_barkoder.startScanning((result) {
// The result from successful scan is received here
});
}
For the complete usage of the barkoder_flutter plugin please check our demo app.
permissions, configured in your app for the barcode scanner to function properly.
- For Android, the permission is set in the manifest from the plugin. Here's an example of how to add the camera permission:
- Open the AndroidManifest.xml file located in the android/app/src/main directory of your Flutter project.
- Locate the <manifest> tag and add the following permission declaration inside it:
uses-permission android:name="android.permission.CAMERA" />
- For iOS you need to specify camera permission in Info.plist file inside your project
<key>NSCameraUsageDescription</key>
<string>Camera permission</string>
The plugin requires a minimum SDK version of 21, but if your Flutter project's Android SDK version is set to 20 or lower, you'll need to update the minSdkVersion in your build.gradle file to at least 21:
android {
compileSdkVersion 33
defaultConfig {
applicationId "com.example.my_flutter_app"
minSdkVersion 21 // Updated to 21
targetSdkVersion 33
versionCode 1
versionName "1.0"
multiDexEnabled true
}
...
}
Run your Flutter app using flutter run
.
Barcode Scanner by barKoder showcases the enterprise-grade performance of the barKoder Barcode Scanner SDK along with most of its features in a wide variety of scanning scenarios.
Wheter from 1D or 2D barcodes, the barKoder API can capture the data reliably, accurately and suprisingly fast, even under very challnging conditions and environments.
You can test the barKoder Barcode Scanner SDK at your convenience by signing up for a free trial
BarcodeType.code93,
BarcodeType.code39,
BarcodeType.codabar,
BarcodeType.code11,
BarcodeType.upcA,
BarcodeType.upcE,
BarcodeType.ean13,
BarcodeType.ean8,
BarcodeType.code25,
BarcodeType.interleaved25,
BarcodeType.itf14,
BarcodeType.telepen,
BarcodeType.aztec,
BarcodeType.aztecCompact,
BarcodeType.qr,
BarcodeType.qrMicro,
BarcodeType.datamatrix,
BarcodeType.pdf417,
BarcodeType.pdf417Micro,
BarcodeType.dotcode,
Sets the decoding speed for barcode scanning.
Example usage:
DecodingSpeed speed = DecodingSpeed.fast;
_barkoder.setDecodingSpeed(speed);
print('Decoding speed set to:$speed');
Sets the resolution for barcode scanning.
Example usage:
BarkoderResolution resolution = BarkoderResolution.HIGH;
await _barkoder.setBarkoderResolution(resolution);
print('Barkoder resolution set to:$resolution');
To add continuous scanning we need to disable close session on result and image result:
_barkoder.setCloseSessionOnResultEnabled(false);
_barkoder.setImageResultEnabled(false);
Sets the threshold between duplicate scans.
int threshold = 1;// 100 milliseconds
_barkoder.setThresholdBetweenDuplicatesScans(threshold);
print('Threshold between duplicate scans set to:$threshold milliseconds');
Sets whether pinch to zoom is enabled.
Example usage:
bool pinchToZoomEnabled = true;
_barkoder.setPinchToZoomEnabled(pinchToZoomEnabled);
print('Pinch to zoom enabled:$pinchToZoomEnabled');
Enables or disables the audible beep sound upon successfully decoding a barcode.
Example usage:
bool beepOnSuccessEnabled = true;
await _barkoder.setBeepOnSuccessEnabled(beepOnSuccessEnabled);
print('Beep on success enabled:$beepOnSuccessEnabled');
Enables or disables the device vibration upon successfully decoding a barcode.
Example usage:
bool vibrateOnSuccessEnabled = true;
await _barkoder.setVibrateOnSuccessEnabled(vibrateOnSuccessEnabled);
print('Vibrate on success enabled:$vibrateOnSuccessEnabled');
Sets whether the detection of misshaped 1D barcodes is enabled
Future<void> setEnableMisshaped1DEnabled(bool enabled)
Sets whether the deblurring feature for UPC/EAN barcodes is enabled
Example usage:
bool isEnabled =true;
await _barkoder.setUpcEanDeblurEnabled(isEnabled);
print('UPC/EAN deblur enabled set to:$isEnabled');
Sets the formatting type for barcode scanning.
Example usage:
FormattingType type = FormattingType.gs1;
_barkoder.setFormattingType(type);
print('Formatting type set to:$type');
Sets the encoding character set for barcode scanning
Example usage:
String characterSet = 'utf-8';
_barkoder.setEncodingCharacterSet(characterSet);
print('Encoding character set set to:$characterSet');
Sets the visibility of the Region of Interest (ROI) on the camera preview.
Example usage:
bool roiVisible =true;
await _barkoder.setRegionOfInterestVisible(roiVisible);
print('Region of interest set to visible:$roiVisible');
The mobile barcode reader SDK by barKoder is designed to allow barcode scanning even without a valid license. However, to maintain security and privacy, all scanning results are obfuscated with (*) asterisk characters. In order to alleviate that you can either get a trial license (to test the software out) or procure a production license that can be used within a production app.