https://github.com/piotrfleury/camcode
a Flutter web camera barcode scan library
https://github.com/piotrfleury/camcode
Last synced: 28 days ago
JSON representation
a Flutter web camera barcode scan library
- Host: GitHub
- URL: https://github.com/piotrfleury/camcode
- Owner: PiotrFLEURY
- License: bsd-3-clause
- Created: 2021-02-28T16:16:28.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2023-09-09T07:10:51.000Z (over 1 year ago)
- Last Synced: 2025-03-26T03:33:12.281Z (about 2 months ago)
- Language: Dart
- Homepage: https://camcode-59c70.web.app/#/
- Size: 216 KB
- Stars: 11
- Watchers: 3
- Forks: 11
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# camcode
A camera barcode scan library for Flutter Web

# Getting Started
## Add a javascript file for barcode scan
```
function detectBarcode(dataUrl, callback) {// call here your favorite javascript barcode scan library
// input must be an image dataUrl
// output must be a single String// don't forget to trigger the call back in order to get the result
callback(barcode);
}
```## Import javascript files into your index.html
```
// the javascript file with the detectBarcode function
```## Use it
```
import 'package:camcode/cam_code_scanner.dart';showDialog(
context: context,
builder: (context) => CamCodeScanner(
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height,
refreshDelayMillis: 200,
onBarcodeResult: (barcode) {
// do whatever you want
},
minimalResultCount: 2,
),
);
```# More options
## Manually release resources
Sometimes, depending on your camcode usage, you may need to release resources manually.
1- To do so, create first a controller for the scanner
```dart
// Create a controller to send instructions to scanner
final CamCodeScannerController _controller = CamCodeScannerController();
```2- Then, add it to the `CamCodeScanner`
```dart
CamCodeScanner(
width: ...,
height: ...,
refreshDelayMillis: ...,
onBarcodeResult: (barcode) {
...
},
controller: _controller,
),
```3- And finally, just call `releaseResources()` method when required
```dart
ElevatedButton(
onPressed: () {
_controller.releaseResources();
},
child: Text('Release resources'),
),
```> Calling this method will close the camera and stop the scanner process