Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: update mlkit_version to 17.0.2 #3

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
109 changes: 6 additions & 103 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,111 +1,14 @@
.DS_Store
.dart_tool/

# Created by https://www.toptal.com/developers/gitignore/api/flutter,macos,dart
# Edit at https://www.toptal.com/developers/gitignore?templates=flutter,macos,dart
.packages
.pub/

### Dart ###
# See https://www.dartlang.org/guides/libraries/private-files
build/

# Files and directories created by pub
.dart_tool/
.packages
build/
# If you're building an application, you may want to check-in your pubspec.lock
pubspec.lock

# Directory created by dartdoc
# If you don't generate documentation locally you can remove this line.
doc/api/

# Avoid committing generated Javascript files:
*.dart.js
*.info.json # Produced by the --dump-info flag.
*.js # When generated by dart2js. Don't specify *.js if your
# project includes source files written in JavaScript.
*.js_
*.js.deps
*.js.map

### Flutter ###
# Flutter/Dart/Pub related
**/doc/api/
.flutter-plugins
.flutter-plugins-dependencies
.pub-cache/
.pub/
lib/generated_plugin_registrant.dart

# Android related
**/android/**/gradle-wrapper.jar
**/android/.gradle
**/android/captures/
**/android/gradlew
**/android/gradlew.bat
**/android/key.properties
**/android/local.properties
**/android/**/GeneratedPluginRegistrant.java
.idea/

# iOS/XCode related
**/ios/**/*.mode1v3
**/ios/**/*.mode2v3
**/ios/**/*.moved-aside
**/ios/**/*.pbxuser
**/ios/**/*.perspectivev3
**/ios/**/*sync/
**/ios/**/.sconsign.dblite
**/ios/**/.tags*
**/ios/**/.vagrant/
**/ios/**/DerivedData/
**/ios/**/Icon?
**/ios/**/Pods/
**/ios/**/.symlinks/
**/ios/**/profile
**/ios/**/xcuserdata
**/ios/.generated/
**/ios/Flutter/App.framework
**/ios/Flutter/Flutter.framework
**/ios/Flutter/Flutter.podspec
**/ios/Flutter/Generated.xcconfig
**/ios/Flutter/app.flx
**/ios/Flutter/app.zip
**/ios/Flutter/flutter_assets/
**/ios/Flutter/flutter_export_environment.sh
**/ios/ServiceDefinitions.json
**/ios/Runner/GeneratedPluginRegistrant.*

# Exceptions to above rules.
!**/ios/**/default.mode1v3
!**/ios/**/default.mode2v3
!**/ios/**/default.pbxuser
!**/ios/**/default.perspectivev3
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages

### macOS ###
# General
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon

# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

# End of https://www.toptal.com/developers/gitignore/api/flutter,macos,dart
pubspec.lock
3 changes: 3 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions .idea/fast_barcode_scanner.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions .idea/libraries/Dart_SDK.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions .idea/libraries/Flutter_Plugins.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 0 additions & 3 deletions CONTRIBUTING.md

This file was deleted.

File renamed without changes.
137 changes: 107 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,107 @@
# Flutter Barcode Scanner Plugin

## Packages

### fast_barcode_scanner:
code for the cross-platform facing plugin, used to display a camera view within Flutter applications

[![pub package](https://img.shields.io/pub/v/fast_barcode_scanner.svg)](https://pub.dartlang.org/packages/fast_barcode_scanner)

### fast_barcode_scanner_platform_interface:
code for the common platform interface

[![pub package](https://img.shields.io/pub/v/fast_barcode_scanner_platform_interface.svg)](https://pub.dartlang.org/packages/fast_barcode_scanner_platform_interface)

Most developers are likely here as they are looking to use the fast_barcode_scanner plugin. There is a readme file within each directory with more information.


## Issues

If you run into bugs, please raise them on the GitHub repository.
Please do not email them to me, as GitHub is the appropriate place for them and allows for members of the community to answer questions, particularly if I miss the email.

It would also be much appreciated if issues could be limited to actual bugs or feature requests.
If you're looking at how you could use the plugin to do a particular kind of notification, check the example app, which provides detailed code samples for each supported feature.
Also try to check the READMEs first in case you have missed something e.g. platform-specific setup.


## Contributions

The guidelines around submitting pull requests can be found in [CONTRIBUTING.md](CONTRIBUTING.md).
# fast_barcode_scanner

[![pub package](https://img.shields.io/pub/v/fast_barcode_scanner)](https://pub.dev/packages/fast_barcode_scanner)

A fast barcode scanner using **MLKit** (and **CameraX**) on Android and **AVFoundation** on iOS. This package leaves the UI up to the user, but rather gives an access to a camera preview.

*Note*: This plugin is still under development, and some APIs might not be available yet. If you have any issues, ideas or recommendendations, don't hesitate to create an issue or pull request on github. I am using this plugin in production myself and will actively develop and maintain it going forward.

**This plugin required iOS 10.0 and Android sdk version 21 or higher.**

## Installation
Add the following line to your **pubspec.yaml**:
```yaml
fast_barcode_scanner: ^1.1.0
```
### iOS
Add the `NSCameraUsageDescription` key to your `ios/Runner/Info.plist`, like so:
```xml
<key>NSCameraUsageDescription</key>
<string>This app requires access to your phone’s camera solely for scanning barcodes</string>
```

### Android
Change the minimum Android sdk version to 21 (or higher) in your `android/app/build.gradle` file.
```
minSdkVersion 21
```

## Usage
The barcode scanner consists of two main classes `CameraController` and `BarcodeCamera`.
A full example looks like this:
```dart
import 'package:fast_barcode_scanner/fast_barcode_scanner.dart';

class MyScannerScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text('Barcode Scanner')),
body: BarcodeCamera(
types: const [
BarcodeType.ean8,
BarcodeType.ean13,
BarcodeType.code128
],
resolution: Resolution.hd720,
framerate: Framerate.fps30,
mode: DetectionMode.pauseVideo,
onScan: (code) => print(code),
children: [
MaterialPreviewOverlay(animateDetection: false),
BlurPreviewOverlay(),
Positioned(
child: ElevatedButton(
onPressed: () =>
CameraController.instance.resumeDetector(),
child: Text('Resume'),
),
)
],
)
)
}
}
```
As you can see, there are two overlays in the childrens list. These two are included in the package. `MaterialPreviewOverlay` mimics the official [material barcode scanning example](https://material.io/design/machine-learning/barcode-scanning.html#usage). `BlurPreviewOverlay` blurs the screen when a barcode is detected and unblurs it on resuming. These are normal widget, which are shown above the camera preview. Look at their source code to find out, how to react to events from the barcode scanner.

### CameraController
The `CameraController`-singleton manages the camera. It handles all the low level stuff like communicating with native code. It is implemented as a singleton to guarantee that there is always one and the same controller managing the camera. You can access the controller via the `CameraController.instance` attribute. These are the accessible methods:

method |Description
----------------|-------------------------------------------------
`initialize` | Initialized the scanner with the provided config
`pauseDetector` | Actively pauses the scanner
`resumeDetector`| Resumes the scanner from the paused state
`toggleTorch` | toggles the torch on and off
`dispose` | Stops and resets the camera on platform level

You do not have to call `initialize` yourself, if you use the `BarcodeCamera` widget.

### CameraState
`CameraController.instance.state` contains the current state of the scanner.
You can use it to build your own overlay. The following information can be accessed:

Attribute | Description
----------------|-------------------------------------------------
`isInitialized` | Indicated whether the camera is currently initialized
`previewConfig` | A `PreviewConfiguration` that is currently used
`eventNotifier` | A event notifier to react to init or detecting codes
`torchState` | The current state of the torch (on/off)
`hasError` | Indicates whether `error` is null or not
`error` | Access the error produced last

### BarcodeCamera
The `BarcodeCamera` is a widget showing a preview of the camera feed. It calls the `CameraController` in the background for initialization and configuration of the barcode camera.

An overview of all possible configurations (either passed to `BarcodeCamera` or `CameraController.initialize`):

Attribute |Description
-------------|---------------------------------------------------------
`types` | See code types to scan (see `BarcodeType`)
`mode` | Whether to pause the camera on detection
`resolution` | The resolution of the camera feed
`framerate` | The framerate of the camera feed
`position` | Choose between back and front camera (iOS)
`onScan` | The callback when a barcode is scanned
`children` | Widgets to display on top of the preview
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"

def camerax_version = "1.1.0-alpha10"
def mlkit_version = "17.0.0"
def mlkit_version = "17.0.2"
implementation "androidx.camera:camera-camera2:$camerax_version"
implementation "androidx.camera:camera-lifecycle:$camerax_version"

Expand Down
File renamed without changes.
File renamed without changes.
Loading