sunrise_sunset_api

This is sa simple Rapper for the Sunrise-Sunset API written in Dart.

Usage

import 'package:sunrise_sunset_api/src/sunrise_sunset_response.dart';
import 'package:sunrise_sunset_api/sunrise_sunset_api.dart';

void main() async {
  // Use the SunriseSunset class to fetch data
  SunriseSunsetResponse? response = await SunriseSunset.getResults(
    date: DateTime.now().subtract(const Duration(days: 1)), // Yesterday's date
    latitude: 37.7749, // Latitude of San Francisco
    longitude: -122.4194, // Longitude of San Francisco
  );

  if (response != null) {
    print('Sunrise time: ${response.data?.sunrise}');
    print('Sunset time: ${response.data?.sunset}');
  } else {
    print('Failed to fetch data.');
  }
}

Libraries

sunrise_sunset_api