-
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update dependencies and make code improvements
- Loading branch information
Showing
8 changed files
with
75 additions
and
56 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
[![pub package](https://img.shields.io/pub/v/ai_barcode_scanner.svg)](https://pub.dev/packages/ai_barcode_scanner) | ||
[![GitHub Sponsors](https://img.shields.io/github/sponsors/juliansteenbakker?label=Sponsor%20Julian%20Steenbakker!)](https://github.com/sponsors/juliansteenbakker) | ||
|
||
### Screenshots | ||
### Screenshots | ||
|
||
<table> | ||
<tr> | ||
|
@@ -16,59 +16,72 @@ | |
</tr> | ||
</table> | ||
|
||
## Platform Support | ||
|
||
| Android | iOS | macOS | Web | Linux | Windows | | ||
| ------- | --- | ----- | --- | ----- | ------- | | ||
| ✔ | ✔ | ✔ | ✔ | :x: | :x: | | ||
|
||
## Features Supported | ||
|
||
See the example app for detailed implementation information. | ||
|
||
| Features | Android | iOS | macOS | Web | | ||
|------------------------|--------------------|--------------------|-------|-----| | ||
| ---------------------- | ------------------ | ------------------ | ----- | --- | | ||
| analyzeImage (Gallery) | :heavy_check_mark: | :heavy_check_mark: | :x: | :x: | | ||
| returnImage | :heavy_check_mark: | :heavy_check_mark: | :x: | :x: | | ||
| scanWindow | :heavy_check_mark: | :heavy_check_mark: | :x: | :x: | | ||
| barcodeOverlay | :heavy_check_mark: | :heavy_check_mark: | :x: | :x: | | ||
|
||
## Platform Support | ||
|
||
| Android | iOS | macOS | Web | Linux | Windows | | ||
|---------|-----|-------|-----|-------|---------| | ||
| ✔ | ✔ | ✔ | ✔ | :x: | :x: | | ||
## Platform specific setup | ||
|
||
### Android | ||
|
||
This package uses by default the **bundled version** of MLKit Barcode-scanning for Android. This version is immediately available to the device. But it will increase the size of the app by approximately 3 to 10 MB. | ||
|
||
## Platform specific setup | ||
### Android | ||
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 increase 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. | ||
To use this version you must alter the mobile_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. | ||
The alternative is to use the **unbundled version** of MLKit Barcode-scanning for Android. This version is downloaded on first use via Google Play Services. It increases the app size by around 600KB. | ||
|
||
[You can read more about the difference between the two versions here.](https://developers.google.com/ml-kit/vision/barcode-scanning/android) | ||
|
||
To use the **unbundled version** of the MLKit Barcode-scanning, add the following line to your `/android/gradle.properties` file: | ||
|
||
``` | ||
dev.steenbakker.mobile_scanner.useUnbundled=true | ||
``` | ||
|
||
### iOS | ||
|
||
**Add the following keys to your Info.plist file, located in <project root>/ios/Runner/Info.plist:** | ||
NSCameraUsageDescription - describe why your app needs access to the camera. This is called Privacy - Camera Usage Description in the visual editor. | ||
|
||
**If you want to use the local gallery feature from [image_picker](https://pub.dev/packages/image_picker)** | ||
NSPhotoLibraryUsageDescription - describe why your app needs permission for the photo library. This is called Privacy - Photo Library Usage Description in the visual editor. | ||
|
||
Example, | ||
``` | ||
<key>NSCameraUsageDescription</key> | ||
<string>This app needs camera access to scan QR codes</string> | ||
<key>NSPhotoLibraryUsageDescription</key> | ||
<string>This app needs photos access to get QR code from photo library</string> | ||
``` | ||
|
||
``` | ||
<key>NSCameraUsageDescription</key> | ||
<string>This app needs camera access to scan QR codes</string> | ||
<key>NSPhotoLibraryUsageDescription</key> | ||
<string>This app needs photos access to get QR code from photo library</string> | ||
``` | ||
|
||
### macOS | ||
|
||
Ensure that you granted camera permission in XCode -> Signing & Capabilities: | ||
|
||
<img width="696" alt="Screenshot of XCode where Camera is checked" src="https://user-images.githubusercontent.com/24459435/193464115-d76f81d0-6355-4cb2-8bee-538e413a3ad0.png"> | ||
|
||
## Web | ||
|
||
This package uses ZXing on web to read barcodes so it needs to be included in `index.html` as script. | ||
|
||
```html | ||
<script src="https://unpkg.com/@zxing/[email protected]" type="application/javascript"></script> | ||
<script | ||
src="https://unpkg.com/@zxing/[email protected]" | ||
type="application/javascript" | ||
></script> | ||
``` | ||
|
||
## Usage ([ai_barcode_scanner](https://pub.dev/packages/ai_barcode_scanner)) | ||
|
@@ -123,7 +136,6 @@ AiBarcodeScanner( | |
|
||
## Usage ([mobile_scanner](https://pub.dev/packages/mobile_scanner)) | ||
|
||
|
||
## Usage | ||
|
||
Import `package:mobile_scanner/mobile_scanner.dart`, and use the widget with or without the controller. | ||
|
@@ -288,14 +300,14 @@ import 'package:mobile_scanner/mobile_scanner.dart'; | |
The onDetect function returns a BarcodeCapture objects which contains the following items. | ||
|
||
| Property name | Type | Description | | ||
|---------------|---------------|-----------------------------------| | ||
| ------------- | ------------- | --------------------------------- | | ||
| barcodes | List<Barcode> | A list with scanned barcodes. | | ||
| image | Uint8List? | If enabled, an image of the scan. | | ||
|
||
You can use the following properties of the Barcode object. | ||
|
||
| Property name | Type | Description | | ||
|---------------|----------------|-------------------------------------| | ||
| ------------- | -------------- | ----------------------------------- | | ||
| format | BarcodeFormat | | | ||
| rawBytes | Uint8List? | binary scan result | | ||
| rawValue | String? | Value if barcode is in UTF-8 format | | ||
|
@@ -314,7 +326,7 @@ You can use the following properties of the Barcode object. | |
### Constructor parameters for [ai_barcode_scanner](https://pub.dev/packages/ai_barcode_scanner) | ||
|
||
```dart | ||
/// Function that gets Called when barcode is scanned successfully | ||
/// Function that gets Called when barcode is scanned successfully | ||
/// | ||
final void Function(String) onScan; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
|
||
<head> | ||
<!-- | ||
If you are serving your web app in a path other than the root, change the | ||
|
@@ -27,7 +28,7 @@ | |
<link rel="apple-touch-icon" href="icons/Icon-192.png"> | ||
|
||
<!-- Favicon --> | ||
<link rel="icon" type="image/png" href="favicon.png"/> | ||
<link rel="icon" type="image/png" href="favicon.png" /> | ||
|
||
<title>example</title> | ||
<link rel="manifest" href="manifest.json"> | ||
|
@@ -39,21 +40,24 @@ | |
<!-- This script adds the flutter initialization JS code --> | ||
<script src="flutter.js" defer></script> | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/jsQR.min.js"></script> | ||
<script src="https://unpkg.com/@zxing/[email protected]" type="application/javascript"></script> | ||
</head> | ||
|
||
<body> | ||
<script> | ||
window.addEventListener('load', function(ev) { | ||
window.addEventListener('load', function (ev) { | ||
// Download main.dart.js | ||
_flutter.loader.loadEntrypoint({ | ||
serviceWorker: { | ||
serviceWorkerVersion: serviceWorkerVersion, | ||
} | ||
}).then(function(engineInitializer) { | ||
}).then(function (engineInitializer) { | ||
return engineInitializer.initializeEngine(); | ||
}).then(function(appRunner) { | ||
}).then(function (appRunner) { | ||
return appRunner.runApp(); | ||
}); | ||
}); | ||
</script> | ||
</body> | ||
</html> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters