getCountryBy method

Future<Country?> getCountryBy(
  1. bool fun(
    1. Country
    ), {
  2. bool firstCache = true,
  3. bool onErrorTryCache = false,
})

Implementation

Future<Country?> getCountryBy(bool Function(Country) fun,
        {bool firstCache: true, bool onErrorTryCache: false}) async =>
    (await getCountries(firstCache: firstCache))?.fold(
        null,
        (acc, country) => acc != null
            ? acc
            : fun(country)
                ? country
                : null);