Sunrise Sunset

Dart API that provides sunset and sunrise times for a given latitude and longitude. This API is a wrapper around the free Sunset and Sunrise Times API

Phases of the sun and moon

Getting started

You should ensure that you add the dependency in your project.

dependencies:
 sunrise_sunset: "^1.0.2"

You should then run flutter packages upgrade or update your packages in IntelliJ.

Usage

Import the file:

import 'package:sunrise_sunset/sunrise_sunset.dart';

To use simply call the static method SunriseSunset.getResults(...).

Time values in response will be expressed Datetime instances and day_length will be expressed in seconds.

final response = await SunriseSunset.getResults(date: DateTime.now(), latitude: 36.7201600, longitude: -4.4203400);

Parameters

Here is a list of supported parameters to use in the SunriseSunset.getResults() method

|---------------|---------------------------------------------------------| | latitude | No | | longitude | No | | date | Yes (If not present, date defaults to current date) |

Libraries

sunrise_sunset

Dart

VM

dart:ffi
Foreign Function Interface for interoperability with the C programming language. [...]

Web

dart:html
HTML elements and other resources for web-based applications that need to interact with the browser and the DOM (Document Object Model). [...]
dart:js
Low-level support for interoperating with JavaScript. [...]
dart:js_util
Utility methods to efficiently manipulate typed JSInterop objects in cases where the name to call is not known at runtime. You should only use these methods when the same effect cannot be achieved with @JS annotations. These methods would be extension methods on JSObject if Dart supported extension methods.