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.
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.
- package_signature
Retrieve Android package signature (SHA1/SHA256) in a Flutter app.
66Compare - sunrise_sunset_calc
Calculates sunrise and sunset times given latitude, longitude, timezone offset and date.
45Compare - time_machine2
Comprehensive date and time library with support for timezones, calendars, cultures, and parsing.
59Compare - system_clock
Dart timekeeping facilities to get system uptime and elapsed time.
55Compare
Works with
Packages commonly used together with daylight: ones it builds on, ones built on it, and its own family.