TencentGeofenceEvent.fromMap constructor

TencentGeofenceEvent.fromMap(
  1. Map map
)

Implementation

factory TencentGeofenceEvent.fromMap(Map map) {
  TencentLocation? loc;
  final rawLoc = map['location'];
  if (rawLoc is Map) loc = TencentLocation.fromMap(rawLoc);

  Duration? stayed;
  final rawStayed = map['stayedDurationMs'];
  if (rawStayed is num) stayed = Duration(milliseconds: rawStayed.toInt());

  Map<String, Object?>? userInfo;
  final rawInfo = map['userInfo'];
  if (rawInfo is Map) {
    userInfo = <String, Object?>{};
    rawInfo.forEach((k, v) {
      if (k is String) userInfo![k] = v;
    });
  }

  return TencentGeofenceEvent(
    geofenceId: (map['geofenceId'] as String?) ?? '',
    transition:
        GeofenceTransitionCodec.fromWire(map['transition'] as String?) ??
            GeofenceTransition.enter,
    location: loc,
    stayedDuration: stayed,
    userInfo: userInfo,
  );
}