Flutter Health Steps Data, Datatype possibly throwing an error that makes UI Crash

Viewed 182

I have integrated the Flutter Health package in my Flutter App and it works fine on android, although the page throws an error on iOS(P.S. The HealthKit Capability has been added). The UI Does not load and throws the following error

The code that the error points to is as follows,

dynamic stepCount() {
      double steps = 0.0;
      if (_countDataList.isNotEmpty)
        _countDataList.forEach((count) => steps += count.toJson()['value']);
      return steps;
  }

  double caloryCount() {
    double calories = 0;
    if (_caloriesDataList.isNotEmpty)
      _caloriesDataList.forEach((cal) => calories += cal.toJson()['value']);
    return calories;
  }

Output After the ErrorStack Trace of the Error

1 Answers

The solution to this is to pass a double Zero(0.0) as a value for the count variable

Related