byteLength property

int get byteLength

The number of bytes this record occupies when stored on a tag.

Implementation

int get byteLength {
  // Header, type length, and a one-byte payload length.
  var length = 3 + type.length + identifier.length + payload.length;

  // A payload of 256 bytes or more needs the four-byte length instead.
  if (payload.length > 255) length += 3;

  // The ID length byte is present when there is an identifier, and -- per the
  // specification -- always for an empty record.
  if (typeNameFormat == NdefTypeNameFormat.empty || identifier.isNotEmpty) length += 1;

  return length;
}