location property Null safety

Location? location

Implementation

Location? get location {
  if (_userData.containsKey('location')) {
    var locationData = _userData['location'] as Map<String, double>;
    return Location(locationData['latitude'], locationData['longitude']);
  }
  return null;
}
void location=(Location? location)

Implementation

set location(Location? location) {
  if (location != null) {
    var locationData = <String, double?>{
      'latitude': location.latitude,
      'longitude': location.longitude,
    };
    _userData['location'] = locationData;
  } else {
    _userData.remove('location');
  }
  _updateInstance(_userData);
}