Giter VIP home page Giter VIP logo

nfc_io's Introduction

Flutter NFC Reader

NFC

A new flutter plugin to help developers looking to use internal hardware inside Android devices (For now, iOS coming soon) for reading NFC tags.

It starts a reading session that keeps scanning tags until it is manually turned off. You can trigger the stop event manually using a dedicated function.

Supported NFC Format

Platform Supported Tags/Cards
Android NDEF:,A, B, F, V, BARCODE, MIFARE
iOS (Coming Soon) NDEF: NFC TYPE 1, 2, 3, 4, 5

Installation

Add to pubspec.yaml:

dependencies:
  nfc_io:
    git:
      url: [email protected]:agent306/nfc_io.git
      ref: master

and then run the shell command

flutter packages get

import the plugin to your project:

import 'package:nfc_io/nfc_io.dart';

How to use

Android setup

Add these two lines to your AndroidManifest.xml on the top

<uses-permission android:name="android.permission.NFC" />
<uses-feature android:name="android.hardware.nfc"/>

iOS setup

Coming soon...

Read NFC

This function will return a stream, the read session will be kept open until otherwise closed. The stream will return a NfcData model whenever an NFC tag/card is detected. This model contains:

Field Description
id Id of the tag
content Content of the tag (Blank if not an NDEF)
error If any error occurs, null otherwise
status Either none, reading, read, stopped or error
Future<void> startNFC() async {
    StreamSubscription _subscription = NfcIo.startReading.listen((NfcData data) {
        print(data);
    });
}

Stop NFC

Future<void> stopNFC() async {
    if (_subscription != null) {
        _subscription.cancel();
        NfcData result = await NfcIo.stopReading;
        print(result);
    }
}

For better details look at the demo app.

Getting Started

This project is a starting point for a Flutter plug-in package, a specialized package that includes platform-specific implementation code for Android and/or iOS.

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

nfc_io's People

Contributors

xedocn avatar

Stargazers

Kemal Dogan avatar  avatar Masfran avatar  avatar Ryan avatar

Watchers

James Cloos avatar Ncodex avatar Cosimo Sguanci avatar

nfc_io's Issues

Which tags

I wonder if I can talk to FIDO2 hardware devices like yubikeys ?

Read sector blocks data MIFARE Classic 1k

Hi I have tried this plugin and I have read the card mifare classic 1k, but I only got this
{id: 0xxxx, content: TAG: Tech [android.nfc.tech.NfcA, android.nfc.tech.MifareClassic, android.nfc.tech.NdefFormatable], error: , status: NFCStatus.read}

How do I read the block data ?

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.