getWeather method

Public function to get the weather for a given latitude and longitude

Implementation

Future<RequestResponse<OneCallWeather?>> getWeather() async {
  /// Initializing the utilities
  WeatherFactoryUtilities utilities = WeatherFactoryUtilities(
    apiKey: apiKey,
    language: language,
    maxTimeBeforeTimeout: maxTimeBeforeTimeout,
  );

  /// Checking whether connected to the internet
  InternetStatus status = await utilities.connectionCheck();
  if (status == InternetStatus.Connected) {
    /// Handing info to be requested and returning the info
    return _oneCallRequest(
      coords: LocationCoords(
        latitude: locationCoords!.latitude,
        longitude: locationCoords!.longitude,
      ),
    );
  } else {
    /// There is a connection error as connectionCheck() returned InternetStatus.Disconnected
    return RequestResponse<OneCallWeather?>(
      requestStatus: RequestStatus.ConnectionError,
      response: null,
    );
  }
}