• Stars
    star
    366
  • Rank 112,314 (Top 3 %)
  • Language
    Kotlin
  • License
    MIT License
  • Created almost 6 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Flutter NFC reader plugin for iOS and Android

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

Platform Supported NFC Tags
Android NDEF: A, B, F, V, BARCODE
iOS NDEF: NFC TYPE 1, 2, 3, 4, 5

Only Android supports nfc tag writing

Installation

Add to pubspec.yaml:

dependencies:
  flutter_nfc_reader: ^0.2.0

or to get the experimental one:

dependencies:
  flutter_nfc_reader:
    git:
      url: git://github.com/matteocrippa/flutter-nfc-reader.git
      ref: develop

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" />
<uses-feature
        android:name="android.hardware.nfc"
        android:required="true" />

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

defaultConfig {
...
minSdkVersion 19
...
}

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'
use_frameworks!

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:

FlutterNfcReader.read() and FlutterNfcReader.onTagDiscovered() have an optional parameter, only for iOS, called instruction. You can pass a String that contains information to be shown in the modal screen.

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

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) {
  print(onData.id);
  print(onData.content);
});

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) {
print(response.content);
});

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) {
    print(response.status.toString());
});

For better details look at the demo app.

Check NFC Availability

In order to check whether the Device supports NFC or not you can call FlutterNfcReader.checkNFCAvailability(). The method returns NFCAvailability.available when NFC is supported and enabled, NFCAvailability.disabled when NFC is disabled (Android only) and NFCAvailability.not_supported when the user's hardware does not support NFC.

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:

flutter/flutter#20685

More Repositories

1

awesome-swift

A collaborative list of awesome Swift libraries and resources. Feel free to contribute!
Ruby
24,240
star
2

awesome-conferences-database

📲 A collaborative list of Conferences
Kotlin
495
star
3

awesome-vim

A collaborative list of awesome vim resources. Feel free to contribute!
158
star
4

karamba

A collection of useful Kotlin extension for Android
Kotlin
51
star
5

awesome-kotlin

A collaborative list of awesome Kotlin libraries and resources. Feel free to contribute!
Kotlin
45
star
6

awesome-swift-ios

Official repository for Awesome Swift iOS App
Swift
43
star
7

leafminer

A FOSS bitcoin miner for ESP8266 and ESP32
C
27
star
8

Raincoat

🧥 Analytics abstraction layer for Kotlin
Kotlin
24
star
9

Parrot

A simple way to handle remote image in Kotlin.
Kotlin
22
star
10

MCFontAwesome

Font Awesome support in Swift
Swift
18
star
11

dsl-n55u-bender

DSL-N55U Custom Firmware • Codename Bender
C
14
star
12

iracing-replay-video

iRacing Replay video generator
JavaScript
10
star
13

ResearchKit-ColorBlind

Colorblind app - ResearchKit Swift app
Swift
9
star
14

pm-bullring-manifesto

A modern approach to PM (Project Management) fixing the overall amount of time for your project.
7
star
15

microraptor

A deno lightweight middleware for easy REST development.
TypeScript
6
star
16

awesome-kotlin-multiplatform

An awesome collaborative collection of Kotlin Multiplatform libraries
Kotlin
5
star
17

swiftRemoteLogger

Swift Remote Logger tool
Shell
5
star
18

fossil

A typescript validation suite for deno projects
TypeScript
4
star
19

sensor-accelerometer-multiplatform

Kotlin Multiplatform Mobile Accelerometer Sensors Library
Kotlin
4
star
20

gpd-pocket2

Gpd Pocket 2 auto setup script for Archlinux
Shell
4
star
21

Exteptional

when swift extension are exceptional
Swift
4
star
22

BaseTypeAdapter

Kotlin extension for Base adapter for typed object and notification for auto refresh
Kotlin
4
star
23

StoryboardEnum

Swift easy storyboard handler via enum
Shell
3
star
24

lenovo-t480

Lenovo T480 autosetup script for Manjaro/ArchLinux
Shell
3
star
25

UIGradientView

Easy gradient view in swift
Shell
3
star
26

BeaconEmitter

Swift beacon emitter built on top of CoreBluetooth
Shell
3
star
27

SecondScreen

Second Screen manager
Shell
3
star
28

Database

A realm singleton protocol for generic database
Swift
3
star
29

StringExtension

A swift String extension.
Shell
2
star
30

UIViewExtension

UIView extension pod
Shell
2
star
31

RunOnce

A wrapper to easily run once a function or set a fallback one
Swift
2
star
32

RedOctober

Experimental swift library to communicate via Bluetooth in a cross platform environment w/out connection
Swift
2
star
33

request-has-body

JavaScript
2
star
34

nodejs-security

Nodejs Security aims to be the best all-in-one solution to your home security. It will allow you to monitor multiple ip-camers thanks to motion control system.
2
star
35

request-has-param

JavaScript
2
star
36

Palindrome-Playground

Swift 3 Palindrome Playground
Swift
2
star
37

passwger-core

Passwger // Open source password manager
HTML
2
star
38

dogbreedjsondatabase

Dog breeds json database
2
star
39

docker-ubuntu-zbar

Docker with Ubuntu 16.04, Nodejs, Python and ZBar
2
star
40

BatSignal

Experimental swift library to communicate via high frequency tones
Objective-C
2
star
41

gitlab2slack

Gitlab 2 slack gateway
JavaScript
1
star
42

polymerTutorial

Polymer Simple Tutorial
HTML
1
star
43

loopback-get-current-user

JavaScript
1
star
44

Debug-Remote

Remote module for Debug swift
JavaScript
1
star
45

ComposeEmail

A quick android wrapper to compose email. Written in kotlin
Kotlin
1
star
46

edgetx-x9lite-firmware

Github automation to build Taranis x9 lite
1
star
47

palindrome-word-api

A JSON api that returns palindrome words
TypeScript
1
star
48

SchedulerAction

An action/function/lambda scheduler with start, stop, pause function
Kotlin
1
star
49

realbounce.js

Realbounce is a GA plugin to allow tracking real user bounces
JavaScript
1
star
50

multichain-nodejs-poc

A poc for docker multi chain
JavaScript
1
star
51

QREncoder

Easy QrCode Encoder for swift
Shell
1
star
52

shakesheare-core

A crossplatform pre-sharing file encryption/decryption tool
JavaScript
1
star
53

docker-ubuntu-opencv

OpenCV enabled Ubuntu 16.04
Shell
1
star
54

Speech

An easy wrapper over AVFoundation with shared instance to text to speech
Swift
1
star
55

swiftRemoteLoggerPhp

Swift remote Logger tool server in php
PHP
1
star
56

docker-ubuntu-tesseract

1
star
57

Spinner

Show a Spinner while your app is thinking
Swift
1
star
58

rgbledmatrix

Rgb Led Matrix SPI Library for Arduino
C++
1
star
59

node-qrcode-docker

A complete docker for qrcode decoding
1
star
60

loopback-docker

1
star
61

stock-marquee-esp32

ESP32 based LED marquee screen for stocks
C
1
star
62

youtube-element

Polymer Youtube Element
HTML
1
star
63

efatturiamo

Localstorage POC for invoices
JavaScript
1
star
64

node-docker-volume

A simple nodejs docker with volume mouting active
1
star
65

cobalt-raq-lcdshowip

Cobalt Raq server LCD script that allow you to show your IP address and other interesting details about your device.
1
star
66

FragmentContextivity

A context/fragment instance getter with support for API < 22
Kotlin
1
star