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 TagPigeon?;
  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(),
          ),
  );
}