Created
January 13, 2022 10:50
-
-
Save tkreuder/557e6ba770a75fc1948698a8d21ed651 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:intl/intl.dart'; | |
class GroupedData<T> { | |
const GroupedData( | |
{required this.startDate, this.endDate, required this.data}); | |
final DateTime startDate; | |
final DateTime? endDate; | |
final List<T> data; | |
} | |
class GaitData { | |
GaitData({ | |
this.strides, | |
}); | |
final Strides? strides; | |
} | |
class Strides { | |
Strides({ | |
this.leftFoot, | |
this.rightFoot, | |
}); | |
final List<dynamic>? leftFoot; | |
final List<dynamic>? rightFoot; | |
} | |
main() { | |
GroupedData<GaitData>? referenceGaitData; | |
/// total steps in the time period of the measurement reference | |
int totalReferenceSteps = 0; | |
/// average steps in the time period of the measurement reference | |
int averageReferenceSteps = 0; | |
/// total steps done in the current measurement week | |
int totalSteps = 0; | |
/// average steps done in the current measurement week | |
int averageStepsPerDay = 0; | |
/// maximum steps done on a single day this measurement week | |
int maxStepsInOneDay = 0; | |
/// list containing all step information about each day in this weeks measurement | |
final List<dynamic> stepDays = List<dynamic>.empty(growable: true); | |
if (referenceGaitData != null && referenceGaitData.data.isNotEmpty) { | |
for (final GaitData singleReferenceGaitDayData in referenceGaitData.data) { | |
if (singleReferenceGaitDayData.strides?.leftFoot != null) { | |
totalReferenceSteps += | |
singleReferenceGaitDayData.strides?.leftFoot?.length ?? 0; | |
} | |
if (singleReferenceGaitDayData.strides?.rightFoot != null) { | |
totalReferenceSteps += | |
singleReferenceGaitDayData.strides?.rightFoot?.length ?? 0; | |
} | |
} | |
if (totalReferenceSteps > 0) { | |
averageReferenceSteps = | |
totalReferenceSteps ~/ referenceGaitData.data.length; | |
} | |
} | |
// .... | |
// Update step days | |
/* | |
stepDays.add(LongitudinalStepDay( | |
steps: stepsThisDay, | |
day: currentLoopGaitDay, | |
)); | |
*/ | |
print('compiles'); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment