getTimeline method
Future<List<TimelineModel> >
getTimeline({
- DateTime? startDate,
- DateTime? endDate,
- TimeZoneType timeZone = TimeZoneType.local,
Gets detailed timeline data with step counts and timestamps.
This method returns a list of TimelineModel objects, each containing a step count and its corresponding timestamp. This is useful for creating charts, graphs, or detailed step history displays.
Parameters:
startDate: The start date for the timeline (inclusive). If null, defaults to the beginning of available data.endDate: The end date for the timeline (inclusive). If null, defaults to the current date.timeZone: The timezone type for timestamp interpretation. Defaults to TimeZoneType.local.
Returns a list of TimelineModel objects ordered by timestamp.
Example:
// Get timeline for the last month in local timezone
final timeline = await stepsCount.getTimeline(
startDate: DateTime.now().subtract(Duration(days: 30)),
endDate: DateTime.now(),
timeZone: TimeZoneType.local,
);
for (final entry in timeline) {
print('${entry.dateTime}: ${entry.stepCount} steps');
}
Implementation
Future<List<TimelineModel>> getTimeline({
DateTime? startDate,
DateTime? endDate,
TimeZoneType timeZone = TimeZoneType.local,
}) {
return StepsCountPlatform.instance.getTimeline(
startDate: startDate,
endDate: endDate,
timeZone: timeZone,
);
}