Getting Started
1) Install the package
Section titled “1) Install the package”Use the pub tool so the dependency and lockfile stay consistent:
flutter pub add mrt_card_readerOr add it manually in pubspec.yaml:
dependencies: mrt_card_reader: ^0.3.0Then fetch dependencies:
flutter pub get2) Confirm prerequisites
Section titled “2) Confirm prerequisites”3) Configure Android NFC
Section titled “3) Configure Android NFC”Add these entries in your AndroidManifest.xml:
<uses-permission android:name="android.permission.NFC" /><uses-feature android:name="android.hardware.nfc" android:required="true" />4) Configure iOS NFC
Section titled “4) Configure iOS NFC”Add this to your Info.plist:
<key>NFCReaderUsageDescription</key><string>This app needs access to NFC to read MRT card data.</string>
<key>com.apple.developer.nfc.readersession.formats</key><array> <string>TAG</string></array>In Xcode:
- Open your Flutter iOS project in Xcode.
- Select your target.
- Open Signing & Capabilities.
- Add Near Field Communication Tag Reading.
5) Run a basic session
Section titled “5) Run a basic session”import 'package:flutter/material.dart';import 'package:mrt_card_reader/mrt_card_reader.dart';
Future<void> readCard() async { final available = await MrtCardReader.isAvailable(); if (!available) return;
await MrtCardReader.startSession( onStatus: (status) => debugPrint(status), onBalance: (balance) => debugPrint('Balance: $balance'), onTransactions: (transactions) => debugPrint('Items: ${transactions.length}'), onError: (exception) => debugPrint('Error: ${exception.message}'), timeout: const Duration(seconds: 30), );}6) Recommended first production flow
Section titled “6) Recommended first production flow”Pre-check
Call isAvailable() before opening the scan state.
Active scan
Start a session with clear status text while waiting for tap + read completion.
Result + recovery
Render balance and history on success, and show one-tap retry for recoverable errors.
Keep in sync with upstream docs
Section titled “Keep in sync with upstream docs”- Package page: pub.dev/packages/mrt_card_reader
- Example app: GitHub example directory