Coder Social home page Coder Social logo

iezed / flutter_zxing Goto Github PK

View Code? Open in Web Editor NEW

This project forked from khoren93/flutter_zxing

0.0 0.0 0.0 8.82 MB

Flutter plugin for scanning and generating QR codes using the ZXing library, supporting Android, iOS, and desktop platforms

Home Page: https://pub.dev/packages/flutter_zxing

License: MIT License

Shell 0.32% Ruby 4.25% C++ 12.10% C 3.27% Objective-C 0.03% Kotlin 0.89% Dart 61.23% Swift 7.65% HTML 0.82% CMake 9.44%

flutter_zxing's Introduction

ZXScanner

ZXScanner logo

Download on the App Store Download on the Google Play

ZXScanner is a free QR code and barcode scanner app for Android and iOS. It is built using Flutter and the flutter_zxing plugin.

Demo Screenshots

01_scanner_screen  02_creator_screen 

All screenshots for iOS were generated using Fastlane Snap. To generate your own, run the command:

cd zxscanner/ios
bundle exec fastlane screenshots

Flutter ZXing

Flutter ZXing is a Flutter plugin for scanning and generating QR codes using the ZXing (Zebra Crossing) barcode scanning library. The plugin is implemented using the Dart FFI (Foreign Function Interface) and the zxing-cpp library, and allows you to easily integrate barcode scanning and generation functionality into your Flutter apps.

Features

  • Scan QR codes and barcodes from the camera stream (on mobile platforms only), image file or URL
  • Scan multiple barcodes at once from the camera stream (on mobile platforms only), image file or URL
  • Generate QR codes with customizable content and size
  • Return the position points of the scanned barcode
  • Customizable scanner frame size and color, and ability to enable or disable features like torch and pinch to zoom

Supported Formats

Linear product Linear industrial Matrix
UPC-A Code 39 QR Code
UPC-E Code 93 Micro QR Code
EAN-8 Code 128 Aztec
EAN-13 Codabar DataMatrix
DataBar DataBar Expanded PDF417
ITF MaxiCode (partial)

Supported platforms

Flutter ZXing supports the following platforms:

  • Android (minimum API level 21)
  • iOS (minimum iOS 11.0)
  • MacOS (minimum osx 10.15) (beta)
  • Linux (beta)
  • Windows (beta)

Note that flutter_zxing relies on the Dart FFI (Foreign Function Interface) feature, which is currently only available for the mobile and desktop platforms. As a result, the plugin is not currently supported on the web platform.

In addition, flutter_zxing uses the camera plugin to access the device's camera for scanning barcodes. This plugin is only supported on mobile platforms, and is not available for desktop platforms. Therefore, some features of flutter_zxing, such as scanning barcodes using the camera, are not available on desktop platforms.

Generated by ChatGPT

This README file was mainly generated using ChatGPT, a tool that generates human-like text.

Getting Started

Cloning the flutter_zxing project

To clone the flutter_zxing project from Github which includes submodules, use the following command:

git clone --recursive https://github.com/khoren93/flutter_zxing.git

Installing dependencies

Use Melos to install the dependencies of the flutter_zxing project. Melos is a tool that helps you manage multiple Dart packages in a single repository. To install Melos, use the following command:

flutter pub global activate melos

To install the dependencies of the flutter_zxing project, use the following command:

melos bootstrap

To allow the building on iOS and MacOS, you need to run the following command:

cd scripts
sh update_ios_macos_src.sh

Now you can run the flutter_zxing example app on your device or emulator.

Usage

To read barcode

import 'package:flutter_zxing/flutter_zxing.dart';

// Use ReaderWidget to quickly read barcode from camera image
@override
Widget build(BuildContext context) {
    return Scaffold(
        body: ReaderWidget(
            onScan: (result) async {
                // Do something with the result
            },
        ),
    ),
);

// Or use flutter_zxing plugin methods 
// To read barcode from camera image directly
await zx.startCameraProcessing(); // Call this in initState

cameraController?.startImageStream((image) async {
    Code result = await zx.processCameraImage(image);
    if (result.isValid) {
        debugPrint(result.text);
    }
    return null;
});

zx.stopCameraProcessing(); // Call this in dispose

// To read barcode from XFile, String, url or Uint8List bytes
XFile xFile = XFile('Your image path');
Code? resultFromXFile = await zx.readBarcodeImagePath(xFile);

String path = 'Your local image path';
Code? resultFromPath = await zx.readBarcodeImagePathString(path);

String url = 'Your remote image url';
Code? resultFromUrl = await zx.readBarcodeImageUrl(url);

Uint8List bytes = Uint8List.fromList(yourImageBytes);
Code? resultFromBytes = await zx.readBarcode(bytes);

To create barcode

import 'package:flutter_zxing/flutter_zxing.dart';
import 'dart:typed_data';
import 'package:image/image.dart' as imglib;

// Use WriterWidget to quickly create barcode
@override
Widget build(BuildContext context) {
    return Scaffold(
        body: WriterWidget(
            onSuccess: (result, bytes) {
                // Do something with the result
            },
            onError: (error) {
                // Do something with the error
            },
        ),
    ),
);

// Or use FlutterZxing to create barcode directly
final Encode result = zx.encodeBarcode(
    contents: 'Text to encode',
    params: EncodeParams(
        format: Format.QRCode,
        width: 120,
        height: 120,
        margin: 10,
        eccLevel: EccLevel.low,
    ),
);
if (result.isValid) {
    final img = imglib.Image.fromBytes(width, height, result.data);
    final encodedBytes = Uint8List.fromList(imglib.encodeJpg(img));
    // use encodedBytes as you wish
}

License

MIT License. See LICENSE.

flutter_zxing's People

Contributors

axxel avatar bounty1342 avatar dependabot[bot] avatar giuliatesta avatar h1376h avatar khoren93 avatar lucasnsa avatar softkot avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.