setFeedbackOptions static method

Future<void> setFeedbackOptions({
  1. String? defaultText,
  2. String? browserUrl,
  3. bool emailFieldVisible = true,
  4. bool emailMandatory = false,
  5. bool takeScreenshotButtonVisible = true,
  6. bool recordVideoButtonVisible = true,
  7. List<FeedbackFormField>? feedbackFormFields,
  8. dynamic onFeedbackSent(
    1. FeedbackContent
    ) = emptyFeedbackContentFunction,
  9. dynamic onFeedbackCancelled() = emptyFunction,
  10. dynamic onFeedbackFailed(
    1. FeedbackContent
    ) = emptyFeedbackContentFunction,
})

Customizes the feedback form.

Implementation

static Future<void> setFeedbackOptions(
    {String? defaultText,
    String? browserUrl,
    bool emailFieldVisible = true,
    bool emailMandatory = false,
    bool takeScreenshotButtonVisible = true,
    bool recordVideoButtonVisible = true,
    List<FeedbackFormField>? feedbackFormFields,
    Function(FeedbackContent) onFeedbackSent = emptyFeedbackContentFunction,
    Function() onFeedbackCancelled = emptyFunction,
    Function(FeedbackContent) onFeedbackFailed =
        emptyFeedbackContentFunction}) async {
  TestFairyBase.prepareTwoWayInvoke();

  final Map<String, dynamic> args = <String, dynamic>{
    'defaultText': defaultText,
    'browserUrl': browserUrl,
    'emailFieldVisible': emailFieldVisible,
    'emailMandatory': emailMandatory,
    'takeScreenshotButtonVisible': takeScreenshotButtonVisible,
    'recordVideoButtonVisible': recordVideoButtonVisible,
    'feedbackFormFields': feedbackFormFields != null
        ? feedbackFormFields
            .map((FeedbackFormField e) => e.toMap())
            .toList(growable: false)
        : null,
    'callId': TestFairyBase.feedbackOptionsIdCounter
  };

  TestFairyBase.feedbackOptionsCallbacks
      .putIfAbsent(TestFairyBase.feedbackOptionsIdCounter.toString(), () {
    return <String, dynamic>{
      'onFeedbackSent': onFeedbackSent,
      'onFeedbackCancelled': onFeedbackCancelled,
      'onFeedbackFailed': onFeedbackFailed
    };
  });

  TestFairyBase.feedbackOptionsIdCounter++;

  await TestFairyBase.channel.invokeMethod<void>('setFeedbackOptions', args);
}