NdefRecord constructor
NdefRecord({
- required TypeNameFormat typeNameFormat,
- required Uint8List type,
- required Uint8List identifier,
- required Uint8List payload,
Constructs an NDEF record from its fields.
Throws FormatException if a valid record cannot be created.
Implementation
factory NdefRecord({
required TypeNameFormat typeNameFormat,
required Uint8List type,
required Uint8List identifier,
required Uint8List payload,
}) {
switch (typeNameFormat) {
case TypeNameFormat.empty:
if (type.isNotEmpty || identifier.isNotEmpty || payload.isNotEmpty) {
throw FormatException('Unexpected data in EMPTY record.');
}
case TypeNameFormat.unknown:
if (type.isNotEmpty) {
throw FormatException('Unexpected type field in UNKNOWN record.');
}
case TypeNameFormat.unchanged:
throw FormatException(
'Unexpected UNCHANGED record in first chunk or logical record.',
);
default:
break;
}
return NdefRecord._(
typeNameFormat: typeNameFormat,
type: type,
identifier: identifier,
payload: payload,
);
}