Skip to content
pubscout

daylight

3.1.0, released 3 years ago by blue-fire.xyz

Calculate sunrise and sunset times for a location without using any remote API.

WASM-ready
$ flutter pub add daylight
Source repository

What it does

The package implements the classic sunrise/sunset algorithm to compute solar events for a given latitude and longitude. It returns results in UTC and works on all Dart platforms without network access.

AI-written summary of version 3.1.0, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You need offline sunrise/sunset calculations
  • You want a lightweight, pure‑Dart solution that works on mobile, web, and desktop
  • You already have the location coordinates and just need solar times

Skip it when

  • You require high‑precision astronomical data beyond the basic algorithm
  • You need automatic timezone conversion or locale‑aware formatting
  • You need additional solar events like twilight phases not provided

Strengths

  • No network or platform‑specific dependencies
  • Pure Dart, works everywhere
  • Simple API and small footprint

Weaknesses

  • Limited to basic sunrise/sunset calculations
  • Outputs only UTC, no built‑in timezone handling
  • Accuracy depends on the algorithm’s assumptions

Setup

Kind
Pure Dart
Effort
Low
Code generation
No
Direct dependencies
1
import 'package:daylight/daylight.dart';

final location = DaylightLocation(52.518611, 13.408056);
final calculator = DaylightCalculator(location);
final results = calculator.calculateForDay(DateTime.now(), Zenith.official);
print('Sunrise: ${results.sunrise}');
print('Sunset: ${results.sunset}');

Alternatives

Packages that do the same job and could replace daylight.

Works with

Packages commonly used together with daylight: ones it builds on, ones built on it, and its own family.