Model Riverpod

State

class MapState {
  final CountryDetails? currentCountry;

  final CountryDetails? compareWithCountry;
  final CountryDetails? compareWithCountry2;
  final City? currentCity;

  MapState({this.currentCountry, this.compareWithCountry, this.compareWithCountry2});

  MapState.initial() : currentCountry = null;

  MapState copyWith(CountryDetails? currentCountry, CountryDetails? compareWithCountry, CountryDetails? compareWithCountry2) {
    return MapState(currentCountry: currentCountry ?? this.currentCountry, 
            compareWithCountry: compareWithCountry ?? this.compareWithCountry,
            compareWithCountry2: compareWithCountry2 ?? this.compareWithCountry2);
  }
}

Notifier

class MapStateNotifier extends StateNotifier<MapState> {
  final Ref _ref;

  MapStateNotifier(this._ref) : super(MapState.initial());

  void setCurrentCountry(String? isoCountryCode);
  void setCompareCountry(String? isoCountryCode);
  void setCurrentCity(String? isoCountryCode);
}
Table of Contents