📜  dart 计算示例 - Dart 代码示例

📅  最后修改于: 2022-03-11 14:48:07.698000             🧑  作者: Mango

代码示例1
// A top level function
int computationallyExpensiveTask(int value) {
  var sum = 0;
  for (var i = 0; i <= value; i++) {
    sum += i;
  }
  print('finished');
  return sum;
}

// Call the function on another thread, keeping the UI thread free
final sum = await compute(computationallyExpensiveTask, 1000000000);