nfc_foreground_dispatch 0.0.1 copy "nfc_foreground_dispatch: ^0.0.1" to clipboard
nfc_foreground_dispatch: ^0.0.1 copied to clipboard

PlatformAndroid

Enables Android NFC foreground dispatch to suppress the system NFC handler, allowing your app to claim NFC priority.

example/lib/main.dart

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

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

class MyApp extends StatefulWidget {
  const MyApp({super.key});
  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  String _status = 'NFC Foreground Dispatch: OFF';

  Future<void> _enable() async {
    final result = await NfcForegroundDispatch.enable();
    setState(() {
      _status = result
          ? 'NFC Foreground Dispatch: ON'
          : 'Failed to enable';
    });
  }

  Future<void> _disable() async {
    final result = await NfcForegroundDispatch.disable();
    setState(() {
      _status = result
          ? 'NFC Foreground Dispatch: OFF'
          : 'Failed to disable';
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: const Text('NFC Foreground Dispatch Example')),
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              Text(_status),
              const SizedBox(height: 20),
              ElevatedButton(onPressed: _enable, child: const Text('Enable')),
              const SizedBox(height: 10),
              ElevatedButton(onPressed: _disable, child: const Text('Disable')),
            ],
          ),
        ),
      ),
    );
  }
}
0
likes
150
points
150
downloads

Publisher

unverified uploader

Weekly Downloads

Enables Android NFC foreground dispatch to suppress the system NFC handler, allowing your app to claim NFC priority.

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

flutter

More

Packages that depend on nfc_foreground_dispatch

Packages that implement nfc_foreground_dispatch