How do I do the equivalent of setTimeout + clearTimeout in Dart?
You can use the Timer class
import 'dart:async';
var timer = Timer(Duration(seconds: 1), () => print('done'));
timer.cancel();
If you want to mimic the JavaScript API:
import 'dart:async';
Timer setTimeout(callback, [int duration = 1000]) {
return Timer(Duration(milliseconds: duration), callback);
}
void clearTimeout(Timer t) {
t.cancel();
}