startCustomizedWorkout method

  1. @override
Future<void> startCustomizedWorkout({
  1. required SMKitWorkout workout,
  2. void onHandle(
    1. SMKitStatus
    )?,
})
override

Implementation

@override
Future<void> startCustomizedWorkout({
  required SMKitWorkout workout,
  void Function(SMKitStatus)? onHandle,
}) async {
  final argument = {
    'smWorkout': workout.toJson().toString(),
  };
  final subscription =
      eventChannel.receiveBroadcastStream().listen((Object? event) {
    _onEvent(event, onHandle);
  });
  try {
    await methodChannel.invokeMethod<String>(
        'startCustomizedWorkout', argument);
    subscription.cancel();
  } on PlatformException catch (e) {
    debugPrint('PlatformException: ${e.code} ${e.message}');
  }
}