GeoCodingApi constructor

GeoCodingApi({
  1. String? apiKey,
  2. String? country,
  3. int? limit,
  4. String? language,
  5. List<PlaceType> types = const [PlaceType.address],
  6. BBox? bbox,
  7. Dio? dio,
})

If apiKey is not provided here then it must be provided MapBoxSearch()

Implementation

GeoCodingApi({
  String? apiKey,
  this.country,
  this.limit,
  this.language,
  this.types = const [PlaceType.address],
  this.bbox,
  Dio? dio,
})  :

      /// Assert that the [apiKey] and [MapBoxSearch._apiKey] are not null at same time
      assert(
        apiKey != null || MapBoxSearch.apiKey != null,
        'The API Key must be provided',
      ),
      _dio = dio ?? Dio(),
      _apiKey = apiKey ?? MapBoxSearch.apiKey! {
  _dio.options.baseUrl = _baseUrl;
  _dio.options.queryParameters = {
    'access_token': _apiKey,
    if (country != null) 'country': country,
    if (limit != null) 'limit': limit.toString(),
    if (language != null) 'language': language,
    if (types.isNotEmpty) 'types': types.map((e) => e.value).join(','),
    if (bbox != null) 'bbox': bbox?.asString,
  };
  _dio.options.receiveDataWhenStatusError = true;
}