SpeedSignEvent.fromMap constructor

SpeedSignEvent.fromMap(
  1. Map<Object?, Object?> map
)

Implementation

factory SpeedSignEvent.fromMap(Map<Object?, Object?> map) {
  Uint8List? bytes;
  final raw = map['imageBytes'];
  if (raw is Uint8List) {
    bytes = raw;
  } else if (raw is List) {
    bytes = Uint8List.fromList(raw.cast<int>());
  }
  return SpeedSignEvent(
    imageBytes: bytes,
    speedLimit: (map['speedLimit'] as num?)?.toInt(),
    signType:   map['signType']  as String?,
    timestamp:  (map['timestamp'] as num?)?.toInt() ??
                DateTime.now().millisecondsSinceEpoch,
  );
}