diff --git a/assets/init.js b/assets/init.js index e5cd807..37ad17e 100644 --- a/assets/init.js +++ b/assets/init.js @@ -1227,6 +1227,7 @@ let UI = { * @param title {string} * @param content {string} * @param actions {{text:string, callback: () => void | Promise, style: "text"|"filled"|"danger"}[]} - If callback returns a promise, the button will show a loading indicator until the promise is resolved. + * @returns {Promise} - Resolved when the dialog is closed. * @since 1.2.1 */ showDialog: (title, content, actions) => { @@ -1282,7 +1283,7 @@ let UI = { * Show an input dialog * @param title {string} * @param validator {(string) => string | null | undefined} - A function that validates the input. If the function returns a string, the dialog will show the error message. - * @returns {string | null} - The input value. If the dialog is canceled, return null. + * @returns {Promise} - The input value. If the dialog is canceled, return null. */ showInputDialog: (title, validator) => { return sendMessage({ @@ -1298,7 +1299,7 @@ let UI = { * @param title {string} * @param options {string[]} * @param initialIndex {number?} - * @returns {number | null} - The selected index. If the dialog is canceled, return null. + * @returns {Promise} - The selected index. If the dialog is canceled, return null. */ showSelectDialog: (title, options, initialIndex) => { return sendMessage({ diff --git a/lib/components/js_ui.dart b/lib/components/js_ui.dart index 16b238a..04068e5 100644 --- a/lib/components/js_ui.dart +++ b/lib/components/js_ui.dart @@ -17,7 +17,7 @@ mixin class JsUiApi { App.rootContext.showMessage(message: m.toString()); } case 'showDialog': - _showDialog(message); + return _showDialog(message); case 'launchUrl': var url = message['url']; if (url.toString().isNotEmpty) { @@ -55,7 +55,7 @@ mixin class JsUiApi { } } - void _showDialog(Map message) { + Future _showDialog(Map message) { BuildContext? dialogContext; var title = message['title']; var content = message['content']; @@ -84,7 +84,7 @@ mixin class JsUiApi { child: Text('OK'), )); } - showDialog( + return showDialog( context: App.rootContext, builder: (context) { dialogContext = context;