startAssessment method

  1. @override
Future<void> startAssessment({
  1. required AssessmentTypes type,
  2. String? assessmentID,
  3. Map<String, dynamic>? userData,
  4. bool showSummary = false,
  5. void onHandle(
    1. SMKitStatus
    )?,
})
override

Implementation

@override
Future<void> startAssessment({
  required AssessmentTypes type,
  String? assessmentID,
  Map<String, dynamic>? userData,
  bool showSummary = false,
  void Function(SMKitStatus)? onHandle,
}) async {
  final subscription =
      eventChannel.receiveBroadcastStream().listen((Object? event) {
    _onEvent(event, onHandle);
  });
  try {
    final arg = {
      'type': type.rawValue,
      'id': assessmentID,
      if (userData != null) 'userData': userData,
      'showSummary': showSummary,
    };
    await methodChannel.invokeMethod('startAssessment', arg);
    subscription.cancel();
  } on PlatformException catch (e) {
    debugPrint('PlatformException: ${e.code} ${e.message}');
  }
}