parse_city_eager function

City parse_city_eager({
  1. required String str,
})

Implementation

City parse_city_eager({
  required final String str,
}) {
  final components = str.split(
    ",",
  );
  assert(
    components.length == 6,
    "Each entry must have exactly 6 values.",
  );
  return _CityEagerImpl(
    country: components[0],
    // Some values contain leading spaces, remove them here.
    city: components[1].trimLeft(),
    // Some values contain leading spaces, remove them here.
    accent_city: components[2].trimLeft(),
    region: components[3],
    latitude: double.parse(
      components[4],
    ),
    longitude: double.parse(
      components[5],
    ),
  );
}