getLocationSummary static method
- DateTime? date,
- LocationQuery? query,
Gets a summary of location history.
Implementation
static Future<LocationSummary> getLocationSummary({
DateTime? date,
LocationQuery? query,
}) async {
LocationQuery effectiveQuery;
if (query != null) {
effectiveQuery = query;
} else if (date != null) {
// Create query for the specific day
final startOfDay = DateTime(date.year, date.month, date.day);
final endOfDay = startOfDay.add(const Duration(days: 1));
effectiveQuery = LocationQuery(from: startOfDay, to: endOfDay);
} else {
// Default to today
final now = DateTime.now();
final startOfDay = DateTime(now.year, now.month, now.day);
effectiveQuery = LocationQuery(from: startOfDay, to: now);
}
final locations = await queryLocations(effectiveQuery);
return LocationHistoryCalculator.calculateSummary(locations);
}