【问题标题】:Stop execution of a Dart program until a key is pressed停止执行 Dart 程序,直到按下某个键
【发布时间】:2012-12-22 00:16:12
【问题描述】:

有没有办法在按下某个键之前停止 Dart 进程的执行?

这会是这样的:

  • 在 html 文件中:
<input id="nextstep" type="button" value="nextstep" />
  • 在 dart 文件中:
void main() { 
  while(true) {
    // Do something here to pause the loop 
    // until the nextstep button is pressed
  } 
}

【问题讨论】:

    标签: dart


    【解决方案1】:

    您只需在您的input 上添加一个keyPress 侦听器即可开始一些额外的处理。

    void main() { 
      final input = querySelector("#nextstep");
      input.onKeyPress.listen((e){
        nextProcessingStep();
      });
    } 
    

    【讨论】:

      猜你喜欢
      • 2014-03-28
      • 1970-01-01
      • 1970-01-01
      • 2014-04-26
      • 2023-04-05
      • 1970-01-01
      • 1970-01-01
      • 2021-05-26
      • 1970-01-01
      相关资源
      最近更新 更多