flutter_nfc_compatibility 0.0.4 copy "flutter_nfc_compatibility: ^0.0.4" to clipboard
flutter_nfc_compatibility: ^0.0.4 copied to clipboard

PlatformAndroid

A nfc compatibility plugin for Android. It will differentiate States of NFC (Not Enabled, Not Supported, Enabled)

example/lib/main.dart

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

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

class MyApp extends StatelessWidget {
  @override
  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);

  @override
  _NfcScanState createState() => _NfcScanState();
}

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

  @override
  initState() {
    super.initState();

    writerController.text = 'Flutter NFC Check';
    checkAvailibility();
  }

  void checkAvailibility() async {
    var nfcCompatibility = await FlutterNfcCompatibility.checkNFCAvailability();
    if (nfcCompatibility == NFCAvailability.Enabled) {
      writerController.text = "Enabled";
    } else if (nfcCompatibility == NFCAvailability.Disabled) {
      writerController.text = "Disabled";
    } else {
      writerController.text = "Not Supported";
    }
  }

  @override
  void dispose() {
    // Clean up the controller when the widget is removed from the
    // widget tree.
    writerController.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Column(
      children: <Widget>[
        TextField(
          controller: writerController,
        ),
      ],
    );
  }
}
3
likes
150
points
299
downloads

Publisher

verified publishermymax.uz

Weekly Downloads

A nfc compatibility plugin for Android. It will differentiate States of NFC (Not Enabled, Not Supported, Enabled)

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on flutter_nfc_compatibility