UUID.fromAddress constructor

UUID.fromAddress(
  1. Object address
)

Creates a new UUID form MAC address.

The address type must be String or int.

Implementation

factory UUID.fromAddress(Object address) {
  final node =
      address is String
          ? address.splitMapJoin(':', onMatch: (m) => '')
          : address is int
          ? (address & 0xFFFFFFFFFFFF).toRadixString(16).padLeft(12, '0')
          : throw TypeError();
  // We don't know the timestamp of the bluetooth device, use nil UUID as prefix.
  return UUID.fromString("00000000-0000-0000-0000-$node");
}