Moroccan cities utility for Dart/Flutter

This package represents a utility package for accessing the data of all cities & regions in Morocco, so you can have the option to use it in your app directly without having to search for it or loading it from a remote source via an http request as an example.

## Why this package?
  • This package doesn't require you to load the data from a remote source, so you can use it directly in your app without having to wait for a network request to finish.

  • This package offers both Future and Stream functionalities for getting all data resources, so you can get items as they are ready and listen to them via a StreamBuilder... or you can wait until all resources are ready and use it with a FutureBuilder...

  • The computation happening for loading and modeling the data in this package happens in a separate Isolate, so you can guarantee a seamless and smooth experience in your Flutter app UI.



For getting all Morocco cities as a Stream<MorrocanCity>:

Stream<MorrocanCity> citiesStream = MoroccanCities.instance.citiesStream();

citiesStream.listen((city) {
   print(; // ...

For getting all Morocco cities as a final List<MorrocanCity>:

List<MorrocanCity> cities = await MoroccanCities.instance.cities();
print(cities); // ...
print(; // ...


For getting all Morocco regions as a Stream<MorrocanRegion>:

Stream<MorrocanRegion> regionsStream = MoroccanCities.instance.regionsStream();

regionsStream.listen((region) {
   print(; // ...

For getting all Morocco regions as a final List<MorrocanRegion>:

List<MorrocanRegion> regions = await MoroccanCities.instance.regions();
print(regions); // ...
print(; // ...

Cities by region

For getting all Morocco cities by region as a Stream<MorrocanCity>:

final regions = await MoroccanCities.instance.regions();
Stream<MorrocanCity> citiesByRegionStream = MoroccanCities.instance.citiesByRegionStream(regions.first);

citiesByRegionStream.listen((city) {
   print(; // ...

For getting all Morocco cities by region as a final List<MorrocanCity>:

final regions = await MoroccanCities.instance.regions();
List<MorrocanCity> citiesByRegion = await MoroccanCities.instance.citiesByRegion(regions.first);
print(citiesByRegion); // ...
print(; // ...


If you want to contribute to this package, you can do so by creating a pull request and I'll be happy to review it and merge it if it's good to go, this package is made to offer help for moroccan developers who want to use it in their apps, so any contribution is welcome.


This package is licensed under the MIT license, so you can use it in your apps without any restrictions.


Support for doing something awesome.