How to make window.prompt in Dart? How to make window.prompt in Dart? dart dart

How to make window.prompt in Dart?


You can use js interop to do this:

import 'dart:js';main() {  var result = context.callMethod('prompt', ['Hello from Dart!']);  print(result);}

I'm not sure why this is not available in dart:html. Perhaps file a bug.

Ideally you'd be able to use another UI component library to do this, rather than using window.prompt(). Something like these. But it's still pretty early days, and I'm not sure if there is a good library available yet.

Update:

window.prompt() has be purposefully removed from dart:html to discourage its use as it blocks the execution of script.