Training
Sets training listener
Set up a training listener, and the result is returned through the data stream and saved in the "event" as a TrainBean object.
_blePlugin.trainingEveStm.listen(
(TrainBean event) {
/// Do something with new state,for example:
setState(() {
switch (event.type) {
case TrainType.historyTrainingChange:
_historyTrainList = event.historyTrainList!;
break;
case TrainType.trainingChange:
_trainingInfo = event.trainingInfo;
_typeInfo = _trainingInfo!.type!;
_startTimeInfo = _trainingInfo!.startTime!;
_endTime = _trainingInfo!.endTime!;
_validTime = _trainingInfo!.validTime!;
_steps = _trainingInfo!.steps!;
_distance = _trainingInfo!.distance!;
_calories = _trainingInfo!.calories!;
_hrList = _trainingInfo!.hrList!;
break;
default:
break;
}
});
});
Callback Description(event):
TrainBean:
callback value | callback value type | callback value description |
---|---|---|
type | int | Get the corresponding return value according to type, where type is the value corresponding to TrainType. |
historyTrainList | List< HistoryTrainList > | Historical training information. |
trainingInfo | TrainingInfo | Training information. |
TrainType:
type | value | value description |
---|---|---|
historyTrainingChange | 1 | Gets History Training |
trainingChange | 2 | Gets Training Detail |
HistoryTrainList:
callback value | callback value type | callback value description |
---|---|---|
startTime | long | Training start time |
type | int | The training type |
TrainingInfo:
callback value | callback value type | callback value description |
---|---|---|
type | int | The training type |
startTime | long | Training start time |
endTime | long | Training end time |
validTime | int | Training duration |
steps | int | Steps |
distance | int | Distance |
calories | int | Calories |
hrList | List< int > | heart rate list |
Gets history training
Get historical training details. The query result will be obtained through the trainingEveStm monitoring stream, the return type is historyTrainingChange, and the training detailed data is TrainBean.historyTrainList.
_blePlugin.queryHistoryTraining;
Gets training detail
Get detailed data for training. The query result will be obtained through the trainingEveStm monitoring stream, the return type is trainingChange, and the training detailed data is TrainBean.trainingInfo
_blePlugin.queryTraining(int id);
Parameter Description :
value | value type | value description |
---|---|---|
id | int | id is the id of a training |