PolygonGeofence.fromMap constructor
PolygonGeofence.fromMap( - JsonMap map
)
Implementation
factory PolygonGeofence.fromMap(JsonMap map) {
final identifier = map['identifier'];
final verticesRaw = map['vertices'];
if (identifier is! String || identifier.isEmpty) {
debugPrint('[PolygonGeofence] Warning: Invalid or missing identifier');
}
if (verticesRaw is! List || verticesRaw.length < 3) {
debugPrint(
'[PolygonGeofence] Warning: Invalid vertices (need at least 3)');
}
final vertices = <GeoPoint>[];
if (verticesRaw is List) {
for (final v in verticesRaw) {
if (v is Map) {
vertices.add(GeoPoint.fromMap(Map<String, dynamic>.from(v)));
}
}
}
final extrasData = map['extras'];
return PolygonGeofence(
identifier: identifier is String ? identifier : '',
vertices: vertices,
notifyOnEntry: map['notifyOnEntry'] as bool? ?? true,
notifyOnExit: map['notifyOnExit'] as bool? ?? true,
notifyOnDwell: map['notifyOnDwell'] as bool? ?? false,
loiteringDelay: (map['loiteringDelay'] as num?)?.toInt(),
extras: extrasData is Map ? Map<String, dynamic>.from(extrasData) : null,
);
}