create static method
Builds a media record. Parameters after ; are dropped, since NDEF stores the bare
type.
Implementation
static NdefRecord create(String mimeType, Uint8List data) {
final normalized = mimeType.toLowerCase().trim().split(';').first;
if (normalized.isEmpty) throw ArgumentError.value(mimeType, 'mimeType', 'is empty');
final slashIndex = normalized.indexOf('/');
if (slashIndex <= 0) throw ArgumentError.value(mimeType, 'mimeType', 'must have a major type');
if (slashIndex == normalized.length - 1) throw ArgumentError.value(mimeType, 'mimeType', 'must have a minor type');
return NdefRecord(
typeNameFormat: NdefTypeNameFormat.media,
type: ascii.encode(normalized),
identifier: Uint8List(0),
payload: data,
);
}