Git Product home page Git Product logo

flutter_barcode_scanner's Introduction

flutter_barcode_scanner

A plugin for Flutter apps that adds barcode scanning support on both Android and iOS.

pub package

Demo gif

Try example

Just clone the repository, open the project in Android Studio/ VS Code, open pubspec.yaml and click on Packages get. Connect device and hit run. To run on iPhone you need to run from Xcode first time and just make pod install in example/ios.

Getting Started

Follow the steps for Android and iOS

Android

โšก Don't worry, you don't need to do anything.

iOS

Deployment target : 10 Swift Version : 5

As iOS code is written in Swift so you need to convert your existing iOS codebase to swift (or if you are creating a new project from Android Studio make sure to check Include Swift support for iOS code.) To do that you can create a new project with same name in different location and then just copy iOS folder to existing.(if any changes made before make sure to add these in iOS(swift)). After making codebase in swift make sure that the Swift version is 5 as the code for iOS is written in Swift 5. To use on iOS, open the Xcode and add camera usage description in Info.plist.

<key>NSCameraUsageDescription</key>
<string>Camera permission is required for barcode scanning.</string>

How to use ?

After making the changes in Android ans iOS add flutter_barcode_scanner to pubspec.yaml

dependencies:
  ...
  flutter_barcode_scanner: ^0.0.8
  1. You need to import the package first.

    import 'package:flutter_barcode_scanner/flutter_barcode_scanner.dart';

  2. Then use the scanBarcode method to access barcode scanning.

    String barcodeScanRes = await FlutterBarcodeScanner.scanBarcode(COLOR_CODE,CANCEL_BUTTON_TEXT,isShowFlashIcon);

Here in scanBarcode(COLOR_CODE,CANCEL_BUTTON_TEXT) COLOR_CODE is hex-color which is the color of line in barcode overlay you can pass color of your choice, , CANCEL_BUTTON_TEXT is a text of cancel button on screen you can pass text of your choice and language, isShowFlashIcon is bool value used to show or hide the flash icon.

Credits :

Special thanks to @Harshal Jadhav for helping me for iOS part.

About me ..

E-mail : [email protected]

Amol Gangadhare

flutter_barcode_scanner's People

Contributors

amolgangadhare avatar

Watchers

James Cloos avatar Dartagnan Sabino 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.