commentWithOptions method
Future<String>
commentWithOptions(
- String parentAuthor,
- String parentPermlink,
- String permlink,
- String title,
- String body,
- String jsonMetadata,
- String options,
override
Implementation
@override
Future<String> commentWithOptions(
String parentAuthor,
String parentPermlink,
String permlink,
String title,
String body,
String jsonMetadata,
String options,
) async {
final completer = Completer<String>();
headlessWebView.webViewController?.addJavaScriptHandler(
handlerName: 'onCommentWithOptionsResult',
callback: (args) {
if (!completer.isCompleted) {
completer.complete(args.isNotEmpty ? args[0].toString() : 'null');
}
},
);
await headlessWebView.webViewController?.evaluateJavascript(
source: """
(async () => {
try {
const res = await comment('$parentAuthor', '$parentPermlink', '$permlink', '$title', '$body', ${jsonMetadata.toString()}, ${options.toString()});
window.flutter_inappwebview.callHandler('onCommentWithOptionsResult', res ?? 'null');
} catch (e) {
window.flutter_inappwebview.callHandler('onCommentWithOptionsResult', 'Error: ' + e.toString());
}
})()
""",
);
return completer.future;
}