getWeather method

Future<Tuple2<RequestStatus, OneCallWeather?>> getWeather()

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

Implementation

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

  /// 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 Tuple2(RequestStatus.ConnectionError, null);
  }
}