create static method

NdefRecord create(
  1. String domain,
  2. String type,
  3. Uint8List data
)

Builds an external record. The stored type is domain:type, lowercased.

Implementation

static NdefRecord create(String domain, String type, Uint8List data) {
  final normalizedDomain = domain.trim().toLowerCase();
  final normalizedType = type.trim().toLowerCase();
  if (normalizedDomain.isEmpty) throw ArgumentError.value(domain, 'domain', 'is empty');
  if (normalizedType.isEmpty) throw ArgumentError.value(type, 'type', 'is empty');

  return NdefRecord(
    typeNameFormat: NdefTypeNameFormat.external,
    type: Uint8List.fromList(utf8.encode('$normalizedDomain:$normalizedType')),
    identifier: Uint8List(0),
    payload: data,
  );
}