'Flutter health: ^3.4.4 - getTotalStepsInInterval

i have problem with package health 3.4.4. I need use this code a rebuild to other activities like BLOOD_OXYGEN or ACTIVE_ENERGY_BURNED :

This code is ok:

fetchStepBar() async {
    int? steps;
    int hour = 0;
    int minute = 0;
    int second = 0;
    int millisecond = 0;
    int microsecond = 0;

    final midnight1 = selectedDate == null
        ? DateTime(now.year, now.month, now.day)
        : DateTime(selectedDate!.year, selectedDate!.month, selectedDate!.day);

    final stepstimefetch1 = selectedDate == null
        ? now
        : DateTime(selectedDate!.year, selectedDate!.month, selectedDate!.day,
            hour = 23, minute = 59, second = 59);

    bool requested = await health.requestAuthorization([HealthDataType.STEPS]);

    if (requested) {
      try {
        steps =
            await health.getTotalStepsInInterval(midnight1, stepstimefetch1);
      } catch (error) {
        print("Caught exception in getTotalStepsInInterval: $error");
      }
      
      setState(() {
        _nofStepsday = (steps == null) ? 0 : steps;
      });
    }
  }

I see problem in: health.getTotalStepsInInterval

I tried rebuild code in class HealthFactory:

Future<int?> getTotalActive_energy_burnedInInterval(
    DateTime startDate,
    DateTime endDate,
  ) async {
    final args = <String, dynamic>{
      'startDate': startDate.millisecondsSinceEpoch,
      'endDate': endDate.millisecondsSinceEpoch
    };
    final energy = await _channel.invokeMethod<int?>(
      'getTotalActive_energy_burnedInInterval',
      args,
    );
    return energy;
  }

But!!! The problem I cannot solve is method channel -> 'getTotalActive_energy_burnedInInterval' It didn't works for me. I cannot definite this. Can anybody help me solve this problem? Thanks a lot



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source