getStepCounts method

Future<int> getStepCounts({
  1. DateTime? startDate,
  2. DateTime? endDate,
})

Gets the total step count for a specified date range.

Parameters:

  • startDate: The start date for the range (inclusive). If null, defaults to the beginning of available data.
  • endDate: The end date for the range (inclusive). If null, defaults to the current date.

Returns the sum of all steps recorded within the specified date range.

Example:

// Get steps for the last 7 days
final weekSteps = await stepsCount.getStepCounts(
  startDate: DateTime.now().subtract(Duration(days: 7)),
  endDate: DateTime.now(),
);

Note: Date boundaries are determined by the device's local timezone.

Implementation

Future<int> getStepCounts({DateTime? startDate, DateTime? endDate}) {
  return StepsCountPlatform.instance.getStepCounts(
    startDate: startDate,
    endDate: endDate,
  );
}