presentFeedbackWidget static method

Future<String?> presentFeedbackWidget(
  1. CountlyPresentableFeedback widgetInfo,
  2. String closeButtonText, {
  3. VoidCallback? widgetShown,
  4. VoidCallback? widgetClosed,
})

Present a chosen feedback widget CountlyPresentableFeedback widgetInfo - Get available list of feedback widgets by calling 'getAvailableFeedbackWidgets()' and pass the widget object as a parameter. String closeButtonText - Text for cancel/close button. VoidCallback? widgetShown Callback to be executed when feedback widget is displayed VoidCallback? widgetClosed Callback to be executed when feedback widget is closed Note: widgetClosed is only implemented for iOS returns error or success message

Implementation

static Future<String?> presentFeedbackWidget(CountlyPresentableFeedback widgetInfo, String closeButtonText, {VoidCallback? widgetShown, VoidCallback? widgetClosed}) async {
  if (!_instance._countlyState.isInitialized) {
    String message = '"initWithConfig" must be called before "presentFeedbackWidget"';
    log('presentFeedbackWidget, $message', logLevel: LogLevel.ERROR);
    return message;
  }
  String widgetId = widgetInfo.widgetId;
  String widgetType = widgetInfo.type;
  log('Calling "presentFeedbackWidget":[$presentFeedbackWidget] with Type:[$widgetType]');
  _widgetShown = widgetShown;
  _widgetClosed = widgetClosed;

  List<String> args = [];
  args.add(widgetId);
  args.add(widgetType);
  args.add(widgetInfo.name);
  args.add(closeButtonText);

  String? result;
  try {
    result = await _channel.invokeMethod('presentFeedbackWidget', <String, dynamic>{'data': json.encode(args)});
  } on PlatformException catch (e) {
    result = e.message;
  }

  return result;
}