nfc_check 1.0.0 copy "nfc_check: ^1.0.0" to clipboard
nfc_check: ^1.0.0 copied to clipboard

PlatformAndroid

A Flutter plugin to check for NFC and HCE support on Android devices, and open NFC settings.

example/lib/main.dart

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:nfc_check/nfc_check.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({super.key});

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  final _nfcCheckPlugin = NfcCheck();

  bool isNfcSupported = false;
  bool isNfcEnabled = false;
  bool isHceSupported = false;

  @override
  void initState() {
    super.initState();
    initPlatformState();
  }

  Future<void> initPlatformState() async {
    isNfcSupported = await _nfcCheckPlugin.isNfcSupported();
    isNfcEnabled = await _nfcCheckPlugin.isNfcEnabled();
    isHceSupported = await _nfcCheckPlugin.isHceSupported();
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      home: Scaffold(
        appBar: AppBar(
          title: const Text('NFC Check'),
          centerTitle: true,
          elevation: 2,
        ),
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              Text('NFC Supported: $isNfcSupported'),
              Text('NFC Enabled: $isNfcEnabled'),
              Text('HCE Supported: $isHceSupported'),
              const SizedBox(height: 32),
              ElevatedButton(
                child: const Text('Open NFC Settings'),
                onPressed: () async {
                  try {
                    await _nfcCheckPlugin.openNfcSettings();
                  } catch (e) {
                    if (kDebugMode) {
                      print(e.toString());
                    }
                  }
                },
              ),
            ],
          ),
        ),
      ),
    );
  }
}
0
likes
150
points
154
downloads

Publisher

unverified uploader

Weekly Downloads

A Flutter plugin to check for NFC and HCE support on Android devices, and open NFC settings.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on nfc_check

Packages that implement nfc_check