Place.fromJson constructor

Place.fromJson(
  1. Map<String, dynamic> json, {
  2. bool isLocalSource = false,
  3. bool isEncryptedSource = false,
})

Creates a Place from JSON map.

isLocalSource indicates if the JSON comes from local assets.

Implementation

factory Place.fromJson(
  Map<String, dynamic> json, {
  bool isLocalSource = false,
  bool isEncryptedSource = false,
}) {
  return Place(
    id:
        json['id'] as String? ??
        DateTime.now().millisecondsSinceEpoch.toString(),
    lat: (json['lat'] as num).toDouble(),
    lng: (json['lng'] as num).toDouble(),
    note: json['note'] as String? ?? '',
    timestamp: json['timestamp'] as String? ?? '',
    address: json['address'] as String?,
    isLocal: isLocalSource,
    isEncrypted: isEncryptedSource,
  );
}