from static method

NdefIOS? from(
  1. NfcTag tag
)

Creates an instance of this class for the given tag.

Returns null if the tag is not compatible.

Implementation

static NdefIOS? from(NfcTag tag) {
  // ignore: invalid_use_of_protected_member
  final data = tag.data as PigeonTag?;
  final tech = data?.ndef;
  if (data == null || tech == null) return null;
  return NdefIOS._(
    data.handle,
    status: NdefStatusIOS.values.byName(tech.status.name),
    capacity: tech.capacity,
    cachedNdefMessage: tech.cachedNdefMessage == null
        ? null
        : NdefMessage(
            records: tech.cachedNdefMessage!.records
                .map((r) => NdefRecord(
                      typeNameFormat: TypeNameFormat.values.byName(
                        r!.typeNameFormat.name,
                      ),
                      type: r.type,
                      identifier: r.identifier,
                      payload: r.payload,
                    ))
                .toList(),
          ),
  );
}