Skip to content

Commit c09aa3f

Browse files
committed
initial commit
0 parents  commit c09aa3f

File tree

142 files changed

+5635
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

142 files changed

+5635
-0
lines changed

.flutter-plugins

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# This is a generated file; do not edit or check into version control.
2+
mobile_scanner=/Users/arvindsangwan/flutter/.pub-cache/hosted/pub.dartlang.org/mobile_scanner-2.0.0/

.flutter-plugins-dependencies

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"mobile_scanner","path":"/Users/arvindsangwan/flutter/.pub-cache/hosted/pub.dartlang.org/mobile_scanner-2.0.0/","native_build":true,"dependencies":[]}],"android":[{"name":"mobile_scanner","path":"/Users/arvindsangwan/flutter/.pub-cache/hosted/pub.dartlang.org/mobile_scanner-2.0.0/","native_build":true,"dependencies":[]}],"macos":[{"name":"mobile_scanner","path":"/Users/arvindsangwan/flutter/.pub-cache/hosted/pub.dartlang.org/mobile_scanner-2.0.0/","native_build":true,"dependencies":[]}],"linux":[],"windows":[],"web":[{"name":"mobile_scanner","path":"/Users/arvindsangwan/flutter/.pub-cache/hosted/pub.dartlang.org/mobile_scanner-2.0.0/","dependencies":[]}]},"dependencyGraph":[{"name":"mobile_scanner","dependencies":[]}],"date_created":"2022-07-27 01:31:24.417317","version":"3.0.5"}

.gitignore

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Miscellaneous
2+
*.class
3+
*.log
4+
*.pyc
5+
*.swp
6+
.DS_Store
7+
.atom/
8+
.buildlog/
9+
.history
10+
.svn/
11+
migrate_working_dir/
12+
13+
# IntelliJ related
14+
*.iml
15+
*.ipr
16+
*.iws
17+
.idea/
18+
19+
# The .vscode folder contains launch configuration and tasks you configure in
20+
# VS Code which you may wish to be included in version control, so this line
21+
# is commented out by default.
22+
#.vscode/
23+
24+
# Flutter/Dart/Pub related
25+
# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock.
26+
/pubspec.lock
27+
**/doc/api/
28+
.dart_tool/
29+
.packages
30+
build/

.metadata

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# This file tracks properties of this Flutter project.
2+
# Used by Flutter tool to assess capabilities and perform upgrades etc.
3+
#
4+
# This file should be version controlled and should not be manually edited.
5+
6+
version:
7+
revision: f1875d570e39de09040c8f79aa13cc56baab8db1
8+
channel: stable
9+
10+
project_type: package

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
## 0.0.1
2+
3+
* Initial release.
4+
* Added a button to turn the LED on and off.
5+
* Added a button to flip the camera.
6+
* Added a hint text.
7+
* Added a barcode validator.
8+
* Added a QR overlay.

README.md

Lines changed: 188 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,188 @@
1+
# ai_barcode_scanner
2+
3+
[![pub package](https://img.shields.io/pub/v/ai_barcode_scanner.svg)](https://pub.dev/packages/ai_barcode_scanner)
4+
5+
A universal barcode and QR code scanner for Flutter based on MLKit. Uses CameraX on Android, AVFoundation on iOS and Apple Vision & AVFoundation on macOS.
6+
7+
## Platform Support
8+
9+
| Android | iOS | MacOS | Web | Linux | Windows |
10+
| :-----: | :-: | :---: | :-: | :---: | :-----: |
11+
| ✔️ | ✔️ | ✔️ | ✔️ | | |
12+
13+
### Android
14+
SDK 21 and newer. Reason: CameraX requires at least SDK 21.
15+
Also, make sure you upgrade kotlin to the latest version in your project.
16+
17+
This packages uses the **bundled version** of MLKit Barcode-scanning for Android. This version is more accurate and immediately available to devices. However, this version will increas the size of the app with approximately 3 to 10 MB. The alternative for this is to use the **unbundled version** of MLKit Barcode-scanning for Android. This version is older than the bundled version however this only increases the size by around 600KB.
18+
19+
To use this version you must alter the ai_barcode_scanner gradle file to replace `com.google.mlkit:barcode-scanning:17.0.2` with `com.google.android.gms:play-services-mlkit-barcode-scanning:18.0.0`. Keep in mind that if you alter the gradle files directly in your project it can be overriden when you update your pubspec.yaml. I am still searching for a way to properly replace the module in gradle but have yet to find one.
20+
21+
[You can read more about the difference between the two versions here.](https://developers.google.com/ml-kit/vision/barcode-scanning/android)
22+
23+
### iOS
24+
iOS 11 and newer. Reason: MLKit for iOS requires at least iOS 10 and a [64bit device](https://developers.google.com/ml-kit/migration/ios).
25+
26+
**Add the following keys to your Info.plist file, located in <project root>/ios/Runner/Info.plist:**
27+
28+
NSCameraUsageDescription - describe why your app needs access to the camera. This is called Privacy - Camera Usage Description in the visual editor.
29+
30+
**If you want to use the local gallery feature from [image_picker](https://pub.dev/packages/image_picker)**
31+
32+
NSPhotoLibraryUsageDescription - describe why your app needs permission for the photo library. This is called Privacy - Photo Library Usage Description in the visual editor.
33+
34+
### macOS
35+
macOS 10.13 or newer. Reason: Apple Vision library.
36+
37+
### Web
38+
Add this to `web/index.html`:
39+
40+
```html
41+
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/jsQR.min.js"></script>
42+
```
43+
44+
Web only supports QR codes for now.
45+
Do you have experience with Flutter Web development? [Help me with migrating from jsQR to qr-scanner for full barcode support!](https://github.com/juliansteenbakker/ai_barcode_scanner/issues/54)
46+
47+
## Usage
48+
49+
Import `package:ai_barcode_scanner/ai_barcode_scanner.dart`, and use the widget with or without the controller.
50+
51+
If you don't provide a controller, you can't control functions like the torch(flash) or switching camera.
52+
53+
If you don't set allowDuplicates to false, you can get multiple scans in a very short time, causing things like pop() to fire lots of times.
54+
55+
```dart
56+
import 'package:ai_barcode_scanner/ai_barcode_scanner.dart';
57+
58+
/// Simple example of using the barcode scanner.
59+
BarcodeScanner(
60+
onScan: (String value) {
61+
debugPrint(value);
62+
},
63+
),
64+
65+
/// Example of using the barcode scanner with a controller.
66+
BarcodeScanner(
67+
controller: BarcodeScannerController(),
68+
onScan: (String value) {
69+
debugPrint(value);
70+
},
71+
),
72+
73+
/// Example of using the barcode scanner with validation.
74+
/// Validator works on the raw string, not the decoded value.
75+
/// If you want to validate the scanner, use the [validateText] and [validateType] parameters.
76+
BarcodeScanner(
77+
validateText: 'https://',
78+
validateType: ValidateType.startsWith,
79+
controller: BarcodeScannerController(),
80+
onScan: (String value) {
81+
debugPrint(value);
82+
},
83+
),
84+
```
85+
86+
### Parameters of the widget
87+
88+
```dart
89+
/// Function that gets Called when barcode is scanned successfully
90+
final void Function(String) onScan;
91+
92+
/// Function that gets called when a Barcode is detected.
93+
///
94+
/// [barcode] The barcode object with all information about the scanned code.
95+
/// [args] Information about the state of the MobileScanner widget
96+
final Function(Barcode barcode, MobileScannerArguments? args)? onDetect;
97+
98+
/// Validate barcode text with [ValidateType]
99+
/// [validateText] and [validateType] must be set together.
100+
final String? validateText;
101+
102+
/// Validate type [ValidateType]
103+
/// Validator working with single string value only.
104+
final ValidateType? validateType;
105+
106+
/// Set to false if you don't want duplicate barcode to be detected
107+
final bool allowDuplicates;
108+
109+
/// Fit to screen
110+
final BoxFit fit;
111+
112+
/// Barcode controller (optional)
113+
final MobileScannerController? controller;
114+
115+
/// Show overlay or not (default: true)
116+
final bool showOverlay;
117+
118+
/// Overlay border color (default: white)
119+
final Color borderColor;
120+
121+
/// Overlay border width (default: 10)
122+
final double borderWidth;
123+
124+
/// Overlay color
125+
final Color overlayColor;
126+
127+
/// Overlay border radius (default: 10)
128+
final double borderRadius;
129+
130+
/// Overlay border length (default: 30)
131+
final double borderLength;
132+
133+
/// Overlay cut out width (optional)
134+
final double? cutOutWidth;
135+
136+
/// Overlay cut out height (optional)
137+
final double? cutOutHeight;
138+
139+
/// Overlay cut out offset (default: 0)
140+
final double cutOutBottomOffset;
141+
142+
/// Overlay cut out size (default: 300)
143+
final double cutOutSize;
144+
145+
/// Show hint or not (default: true)
146+
final bool showHint;
147+
148+
/// Hint text (default: 'Scan QR Code')
149+
final String hintText;
150+
151+
/// Hint margin
152+
final EdgeInsetsGeometry hintMargin;
153+
154+
/// Hint padding
155+
final EdgeInsetsGeometry hintPadding;
156+
157+
/// Hint background color (optional)
158+
final Color? hintBackgroundColor;
159+
160+
/// Hint text style
161+
final TextStyle hintTextStyle;
162+
163+
/// Show error or not (default: true)
164+
final bool showError;
165+
166+
/// Error color (default: red)
167+
final Color errorColor;
168+
169+
/// Error text (default: 'Invalid BarCode')
170+
final String errorText;
171+
172+
/// Show success or not (default: true)
173+
final bool showSuccess;
174+
175+
/// Success color (default: green)
176+
final Color successColor;
177+
178+
/// Success text (default: 'BarCode Found')
179+
final String successText;
180+
181+
/// Can auto back to previous page when barcode is successfully scanned (default: true)
182+
final bool canPop;
183+
```
184+
185+
## Thanks to
186+
This plugin is based on the [mobile_scanner](https://pub.dev/packages/mobile_scanner) plugin by [steenbakker.dev](https://pub.dev/publishers/steenbakker.dev/packages).
187+
188+
I recommend you to read the [mobile_scanner](https://pub.dev/packages/mobile_scanner) plugin's documentation.

analysis_options.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
include: package:flutter_lints/flutter.yaml
2+
3+
# Additional information about this file can be found at
4+
# https://dart.dev/guides/language/analysis-options

example/.gitignore

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Miscellaneous
2+
*.class
3+
*.log
4+
*.pyc
5+
*.swp
6+
.DS_Store
7+
.atom/
8+
.buildlog/
9+
.history
10+
.svn/
11+
migrate_working_dir/
12+
13+
# IntelliJ related
14+
*.iml
15+
*.ipr
16+
*.iws
17+
.idea/
18+
19+
# The .vscode folder contains launch configuration and tasks you configure in
20+
# VS Code which you may wish to be included in version control, so this line
21+
# is commented out by default.
22+
#.vscode/
23+
24+
# Flutter/Dart/Pub related
25+
**/doc/api/
26+
**/ios/Flutter/.last_build_id
27+
.dart_tool/
28+
.flutter-plugins
29+
.flutter-plugins-dependencies
30+
.packages
31+
.pub-cache/
32+
.pub/
33+
/build/
34+
35+
# Web related
36+
lib/generated_plugin_registrant.dart
37+
38+
# Symbolication related
39+
app.*.symbols
40+
41+
# Obfuscation related
42+
app.*.map.json
43+
44+
# Android Studio will place build artifacts here
45+
/android/app/debug
46+
/android/app/profile
47+
/android/app/release

example/.metadata

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# This file tracks properties of this Flutter project.
2+
# Used by Flutter tool to assess capabilities and perform upgrades etc.
3+
#
4+
# This file should be version controlled.
5+
6+
version:
7+
revision: f1875d570e39de09040c8f79aa13cc56baab8db1
8+
channel: stable
9+
10+
project_type: app
11+
12+
# Tracks metadata for the flutter migrate command
13+
migration:
14+
platforms:
15+
- platform: root
16+
create_revision: f1875d570e39de09040c8f79aa13cc56baab8db1
17+
base_revision: f1875d570e39de09040c8f79aa13cc56baab8db1
18+
- platform: android
19+
create_revision: f1875d570e39de09040c8f79aa13cc56baab8db1
20+
base_revision: f1875d570e39de09040c8f79aa13cc56baab8db1
21+
- platform: ios
22+
create_revision: f1875d570e39de09040c8f79aa13cc56baab8db1
23+
base_revision: f1875d570e39de09040c8f79aa13cc56baab8db1
24+
- platform: linux
25+
create_revision: f1875d570e39de09040c8f79aa13cc56baab8db1
26+
base_revision: f1875d570e39de09040c8f79aa13cc56baab8db1
27+
- platform: macos
28+
create_revision: f1875d570e39de09040c8f79aa13cc56baab8db1
29+
base_revision: f1875d570e39de09040c8f79aa13cc56baab8db1
30+
- platform: web
31+
create_revision: f1875d570e39de09040c8f79aa13cc56baab8db1
32+
base_revision: f1875d570e39de09040c8f79aa13cc56baab8db1
33+
- platform: windows
34+
create_revision: f1875d570e39de09040c8f79aa13cc56baab8db1
35+
base_revision: f1875d570e39de09040c8f79aa13cc56baab8db1
36+
37+
# User provided section
38+
39+
# List of Local paths (relative to this file) that should be
40+
# ignored by the migrate tool.
41+
#
42+
# Files that are not part of the templates will be ignored by default.
43+
unmanaged_files:
44+
- 'lib/main.dart'
45+
- 'ios/Runner.xcodeproj/project.pbxproj'

example/README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# example
2+
3+
A new Flutter project.
4+
5+
## Getting Started
6+
7+
This project is a starting point for a Flutter application.
8+
9+
A few resources to get you started if this is your first Flutter project:
10+
11+
- [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab)
12+
- [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook)
13+
14+
For help getting started with Flutter development, view the
15+
[online documentation](https://docs.flutter.dev/), which offers tutorials,
16+
samples, guidance on mobile development, and a full API reference.

0 commit comments

Comments
 (0)