flutter_nfc_reader 0.1.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 93

Flutter NFC Reader & Writer #

A new flutter plugin to help developers looking to use internal hardware inside iOS or Android devices for reading and writing NFC tags.

The system activate a pooling reading session that stops automatically once a tag has been recognised. You can also trigger the stop event manually using a dedicated function.

Supported NFC Format #

PlatformSupported NFC Tags
AndroidNDEF: A, B, F, V, BARCODE
iOSNDEF: NFC TYPE 1, 2, 3, 4, 5

Only Android supports nfc tag writing #

Installation #

Add to pubspec.yaml:

      url: git://github.com/matteocrippa/flutter-nfc-reader.git
      ref: master

and then run the shell

flutter packages get

last step import to the project:

import 'package:flutter_nfc_reader/flutter_nfc_reader.dart';

How to use #

Android setup #

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

<uses-permission android:name="android.permission.NFC" />
        android:required="true" />

Assign 18 in minSdkVersion in the build.gradle (Module: app)

defaultConfig {
minSdkVersion 18

iOS Setup #

Atm only Swift based Flutter project are supported.

  • Enable Capabilities / Near Field Communication Tag Reading.
  • Info.plist file, add Privacy - NFC Scan Usage Description with string value NFC Tag.

In your Podfile add this code in the top

platform :ios, '8.0'

Read NFC #

This function will return a promise when a read occurs, till that very moment the reading session is open. The promise will return a NfcData model, this model contains:

  • id > id of the tag
  • content > content of the tag
  • error > if any error occurs
FlutterNfcReader.read().then((response) {

Stream NFC #

this function will return a Stream that emits NfcData everytime a tag is recognized. On Ios you can use this too but IOS will always show a bottom sheet when it wants to scan a NFC Tag. Therefore you need to explicitly cast FlutterNfcReader.read() when you expect a second value. When subscribing to the stream the read function is called a first time for you. View the Example for a sample implementation.

FlutterNfcReader.onTagDiscovered().listen((onData) {

Write NFC (Only Android) #

This function will return a promise when a write occurs, till that very moment the reading session is open. The promise will return a NfcData model, this model contains:

  • content > writed in the tag
FlutterNfcReader.write("path_prefix","tag content").then((response) {

Read & Write NFC (Only Android) #

You can read and then write in an nfc tag using the above functions as follows

FlutterNfcReader.read().then((readResponse) {
    FlutterNfcReader.write(" ",readResponse.content).then((writeResponse) {
        print('writed: ${writeResponse.content}');

Stop NFC #

  • status > status of ncf reading or writing stoped
FlutterNfcReader.stop().then((response) {

For better details look at the demo app.

IOS Specifics #

IOS behaves a bit different in terms of NFC Scanning and writing.

  • Ids of the tags aren't possible in the current implementation
  • each scan is visible for the user with a bottom sheet

Getting Started #

For help getting started with Flutter, view our online documentation.

For help on editing plugin code, view the documentation.

Contributing #

Please take a quick look at the contribution guidelines first. If you see a package or project here that is no longer maintained or is not a good fit, please submit a pull request to improve this file. Thank you to all contributors!!

to develop on ios you need to activate the "legacy" build system because of this issue in flutter:


Changelog #

0.1.00 #

  • Total refactor, add write support for Android

0.0.23 #

  • Improved Android support.

0.0.14 #

  • Stable iOS version.
  • Fix issue with importing with Cocoapods.

0.0.5 #

  • iOS fix support for static modules.

0.0.4 #

  • iOS add extra details on readme for usage.

0.0.3 #

  • Flutter required min version is now 0.5.5 as latest stable.

0.0.2 #

  • Name refactoring for functions, more descriptive and synteic.
  • On read event force stopping the pooling in background to optimize usage.

0.0.1 #

  • First release, android untested.


import 'package:flutter/material.dart';
import 'package:flutter_nfc_reader/flutter_nfc_reader.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Material App',
      home: Scaffold(
        appBar: AppBar(
          title: Text('Material App Bar'),
        body: Center(child: NfcScan()),

class NfcScan extends StatefulWidget {
  NfcScan({Key key}) : super(key: key);

  _NfcScanState createState() => _NfcScanState();

class _NfcScanState extends State<NfcScan> {
  TextEditingController writerController = TextEditingController();

  initState() {
    writerController.text = 'Flutter NFC Scan';
    FlutterNfcReader.onTagDiscovered().listen((onData) {

  void dispose() {
    // Clean up the controller when the widget is removed from the
    // widget tree.

  Widget build(BuildContext context) {
    return Column(
      children: <Widget>[
          controller: writerController,
          onPressed: () {
          child: Text("Read"),
          onPressed: () {
            FlutterNfcReader.write(" ", writerController.text).then((value) {
          child: Text("Write"),

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  flutter_nfc_reader: ^0.1.0

2. Install it

You can install packages from the command line:

with Flutter:

$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:flutter_nfc_reader/flutter_nfc_reader.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Apr 4, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.6
  • Flutter: 1.12.13+hotfix.8

Health issues and suggestions

Document public APIs. (-1 points)

24 out of 24 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.19.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8