패키지, 저장소 및 앱 카테고리 검색

패키지 상세v3.0.2

flutter_qr_bar_scanner

Firebase의 Mobile Vision API를 사용하여 QR 및 바코드를 읽고 스캔하는 Flutter 플러그인

AndroidiOS
30일 다운로드
259
좋아요
57
Pub 점수
110

패키지 설치

flutter pub add flutter_qr_bar_scanner

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

Firebase의 Mobile Vision API를 사용하여 QR 및 바코드 스캔을 가능하게 하는 플러터 플러그인입니다. 안드로이드 및 iOS 앱에 스캔 기능을 간단하고 신뢰할 수 있는 방식으로 통합할 수 있도록 합니다. 개발자는 고급 컴퓨터 비전 기술을 활용하여 다양한 바코드 형식을 높은 정확도로 감지하고 디코딩할 수 있습니다. 결제 시스템, 재고 관리 또는 티켓팅 플랫폼과 같은 응용 프로그램에 스캔 기능을 쉽게 구현할 수 있습니다. 패키지는 가볍고 잘 문서화되어 있어 초보자와 숙련된 개발자 모두에게 접근하기 쉽습니다.

사용 사례

  • 재고 추적
  • 결제 처리
  • 티켓 검증
  • 자산 관리
  • 사용자 인증
  • 데이터 입력 자동화

주요 기능

  • Firebase Mobile Vision API 사용
  • QR 및 여러 바코드 유형을 지원합니다
  • 크로스 플랫폼(안드로이드 및 iOS)
  • Flutter와의 간단한 통합
  • 실시간 스캔
  • 고정밀 디코딩

적합한 대상

  • 바코드 스캔이 필요한 모바일 앱
  • Firebase를 사용하는 개발자
  • 빠른 MVP를 구축하는 스타트업
  • 소매 및 물류 앱
  • 이벤트 티켓팅 시스템

고려 사항

  • 초기 설정을 위해 인터넷이 필요합니다 (Firebase)
  • 카메라 UI의 사용자 정의 제한
  • Firebase 종속성에 의존합니다
  • Firebase SDK로 인한 크기 오버헤드 가능성
  • 기기에서 카메라 권한이 필요합니다

원본 README

연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.

Flutter QR Bar Scanner

pub package

A Full Screen Scanner for Scanning QR code and Barcode using Google's Mobile Vision API

Reading & Scanning QR/Bar codes using Firebase's MLKit.

This plugin uses Android & iOS native APIs for reading images from the device's camera. It then pipes these images both to the MLKit Vision Barcode API which detects qr/bar codes etc, and outputs a preview image to be shown on a flutter texture.

The plugin includes a widget which performs all needed transformations on the camera output to show within the defined area.

Android Models

With this new version of MLKit, there are two separate models you can use to do the barcode scanning. Currently, this apk chooses to use the build-in model. This will increase your code size by ~2.2MB but will result in better scanning and won't require a separate package to be downloaded in the background for barcode scanning to work properly.

You could also use the Google Play Services and tell your app to download it on install from the play store. See the instruction on the ml-kit barcode-scanning documentation page for android. You would also have to remove the com.google.mlkit:barcode-scanning dependency;

configurations.all {
    exclude group: "com.google.mlkit", module:"barcode-scanning"
}
//  ...
dependencies {
  // ...
  // Use this dependency to use the dynamically downloaded model in Google Play Services
  implementation 'com.google.android.gms:play-services-mlkit-barcode-scanning:16.1.4'
}

Note that if you do this, you should tell your app to automatically download the model as in the above linked docs.MLKit

<application ...>
    ...
    <meta-data
        android:name="com.google.mlkit.vision.DEPENDENCIES"
        android:value="barcode" />
    <!-- To use multiple models: android:value="barcode,model2,model3" -->
</application>

If this doesn't work for you please open an issue.

64 Bit Only on iOS

The plugin is only supported for only 64 Bit on iOS as Google has only released MLKit as a 64 bit binary.

When you upgrade, if you are targeting a version of iOS before 11, you'll see a warning during the pod install and your app probably won't build (at least for release). That's because it'll be trying to build the 32-bit version and won't find the required files.

The easy way to solve this is by updating to build for iOS 11 and later. To do this:

  1. Add this line to your Podfile:
platform :ios, '11.0'
  1. (optional) Make sure your podfile sets build versions to 11 - if you see this at the bottom of your podfile make sure the line setting the deployment target to 11 is in there.
post_install do |installer|
    installer.pods_project.targets.each do |target|
        target.build_configurations.each do |config|
            config.build_settings['ENABLE_BITCODE'] = 'NO'
            config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '11.0'
        end
    end
end
  1. Setting the iOS Deployment Target to 11 in XCode -> Runner -> Build Settings -> Deployment -> iOS Deployment Target.

Building for 64-bit before 11.0.

If you absolutely need to build for devices before 11.0, you might need to use an old version of the library that supports 32-bit. If you're willing to live without 32 bit but do need to target before 11.0, you can do that by ignoring the warning CocoaPods will give you, and setting XCode -> Runner -> Build Settings -> Architectures -> Architectures to ${ARCHS_STANDARD_64_BIT}.

Usage

See the example for how to use this plugin; it is the best resource available as it shows the plugin in use. However, these are the steps you need to take to use this plugin.

First, figure out the area that you want the camera preview to be shown in. This is important as the preview needs to have a constrained size or it won't be able to build. This is required due to the complex nature of the transforms needed to get the camera preview to show correctly on both iOS and Android, while still working with the screen rotated etc.

It may be possible to get the camera preview to work without putting it in a SizedBox or Container, but the recommended way is to put it in a SizedBox or Container.

You then need to include the package and instantiate the camera.

import 'package:flutter/material.dart';
import 'package:flutter_qr_bar_scanner/qr_bar_scanner_camera.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter QR/Bar Code Reader',
      debugShowCheckedModeBanner: false,
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(title: 'Flutter QR/Bar Code Reader'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key? key, this.title}) : super(key: key);
  final String? title;
  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  String? _qrInfo = 'Scan a QR/Bar code';
  bool _camState = false;

  _qrCallback(String? code) {
    setState(() {
      _camState = false;
      _qrInfo = code;
    });
  }

  _scanCode() {
    setState(() {
      _camState = true;
    });
  }

  @override
  void initState() {
    super.initState();
    _scanCode();
  }

  @override
  void dispose() {
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title!),
      ),
      body: _camState
          ? Center(
              child: SizedBox(
                height: 1000,
                width: 500,
                child: QRBarScannerCamera(
                  onError: (context, error) => Text(
                    error.toString(),
                    style: TextStyle(color: Colors.red),
                  ),
                  qrCodeCallback: (code) {
                    _qrCallback(code);
                  },
                ),
              ),
            )
          : Center(
              child: Text(_qrInfo!),
            ),
    );
  }
}


The QrCodeCallback can do anything you'd like, and wil keep receiving QR/Bar codes until the camera is stopped.

There are also optional parameters to QRScannerCamera.

fit

Takes as parameter the flutter BoxFit. Setting this to different values should get the preview image to fit in different ways, but only BoxFit = cover has been tested extensively.

notStartedBuilder

A callback that must return a widget if defined. This should build whatever you want to show up while the camera is loading (which can take from milliseconds to seconds depending on the device).

child

Widget that is shown on top of the QRScannerCamera. If you give it a specific size it may cause weird issues so try not to.

key

Standard flutter key argument. Can be used to get QRScannerCameraState with a GlobalKey.

offscreenBuilder

A callback that must return a widget if defined. This should build whatever you want to show up when the camera view is 'offscreen'. i.e. when the app is paused. May or may not show up in preview of app.

onError

Callback for if there's an error.

'formats'

A list of supported formats, all by default. If you use all, you shouldn't define any others.

These are the supported types:

  ALL_FORMATS,
  AZTEC,
  CODE_128,
  CODE_39,
  CODE_93,
  CODABAR,
  DATA_MATRIX,
  EAN_13,
  EAN_8,
  ITF,
  PDF417,
  QR_CODE,
  UPC_A,
  UPC_E

Push and Pop

If you push a new widget on top of a the current page using the navigator, the camera doesn't necessarily know about it.

Contributions

Any kind of contribution will be appreciated.

License

MIT License

Inspire me

Be a Patreon

카테고리

의존성

의존성 목록 1 개

소스 저장소

이 패키지를 사용하는 프로젝트

아직 데이터가 없습니다.