sunrise_sunset 1.0.3

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) |

[1.0.0]

  • First release.

[1.0.1]

  • Added example
  • Simplified API

[1.0.2]

  • Updated CHANGELOG.md
  • Enhanced the README.md
  • Added helpful graphic
  • Gave attribution to source REST API

[1.0.3]

  • Updated README.md properties table

example/README.md

Getting the sunset and sunrise times for a parituclar lat/long is very simple.

Get info for lat/lon "today" #

main() async {
  var response = await SunriseSunset.getResults(
        latitude: 39.001735, longitude: -119.752744);

  if (response.success) {
    print('Sunrise: ${response.data.sunrise}');
    print('Sunset: ${response.data.sunset}');
    print('Solar Noon: ${response.data.solar_noon}');
    print('Day Length: ${response.data.day_length}');
    print('Civil Twilight Start: ${response.data.sunset}');
    print('Civil Twilight End: ${response.data.sunset}');
    print('Nautical Twilight Start: ${response.data.sunset}');
    print('Nautical Twilight End: ${response.data.sunset}');
    print('Astronomical Twilight Start: ${response.data.sunset}');
    print('Astronomical Twilight End: ${response.data.sunset}');
  } else {
    print(response.error);
  }
}

Get info for lat/lon for a historical date #

main() async {
  var response = await SunriseSunset.getResults(date: new DateTime.utc(1989, 11, 9);.
        latitude: 39.001735, longitude: -119.752744);

  if (response.success) {
    print('Sunrise: ${response.data.sunrise}');
    print('Sunset: ${response.data.sunset}');
    print('Solar Noon: ${response.data.solar_noon}');
    print('Day Length: ${response.data.day_length}');
    print('Civil Twilight Start: ${response.data.sunset}');
    print('Civil Twilight End: ${response.data.sunset}');
    print('Nautical Twilight Start: ${response.data.sunset}');
    print('Nautical Twilight End: ${response.data.sunset}');
    print('Astronomical Twilight Start: ${response.data.sunset}');
    print('Astronomical Twilight End: ${response.data.sunset}');
  } else {
    print(response.error);
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  sunrise_sunset: ^1.0.3

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:sunrise_sunset/sunrise_sunset.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
54
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
80
Overall:
Weighted score of the above. [more]
73
Learn more about scoring.

We analyzed this package on Feb 19, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.5
  • Flutter: 1.12.13+hotfix.7

Maintenance issues and suggestions

Homepage URL doesn't exist. (-20 points)

At the time of the analysis the homepage field https://aeyrium.com/ was unreachable.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
http ^0.12.0+2 0.12.0+4
Transitive dependencies
async 2.4.0
charcode 1.1.3
collection 1.14.11 1.14.12
http_parser 3.1.3
meta 1.1.8
path 1.6.4
pedantic 1.9.0
sky_engine 0.0.99
source_span 1.6.0
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test
test any