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 valuecallback value typecallback value description
typeintGet the corresponding return value according to type, where type is the value corresponding to TrainType.
historyTrainListList< HistoryTrainList >Historical training information.
trainingInfoTrainingInfoTraining information.

TrainType:

typevaluevalue description
historyTrainingChange1Gets History Training
trainingChange2Gets Training Detail

HistoryTrainList:

callback valuecallback value typecallback value description
startTimelongTraining start time
typeintThe training type

TrainingInfo:

callback valuecallback value typecallback value description
typeintThe training type
startTimelongTraining start time
endTimelongTraining end time
validTimeintTraining duration
stepsintSteps
distanceintDistance
caloriesintCalories
hrListList< 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 :

valuevalue typevalue description
idintid is the id of a training
Last Updated: