doDecode static method
NDEFRecord
doDecode(
- TypeNameFormat tnf,
- Uint8List type,
- Uint8List payload, {
- Uint8List? id,
- TypeFactory typeFactory = NDEFRecord.defaultTypeFactory,
Decode a NDEFRecord record from raw data.
Implementation
static NDEFRecord doDecode(
TypeNameFormat tnf, Uint8List type, Uint8List payload,
{Uint8List? id,
TypeFactory typeFactory = NDEFRecord.defaultTypeFactory}) {
var record = typeFactory(tnf, utf8.decode(type));
if (payload.length < record.minPayloadLength) {
throw ArgumentError(
"Payload length must be >= ${record.minPayloadLength}");
}
if (record.maxPayloadLength != null &&
payload.length < record.maxPayloadLength!) {
throw ArgumentError(
"Payload length must be <= ${record.maxPayloadLength}");
}
record.id = id;
record.type = type;
// use setter for implicit decoding
record.payload = payload;
return record;
}