delay method

StreamSubscription delay(
  1. int milliSeconds,
  2. ValueChanged<T> listen
)

延迟处理 @params milliSeconds 延迟多少毫秒执行

Implementation

StreamSubscription delay(int milliSeconds, ValueChanged<T> listen) {
  final stream = Stream.fromFuture(Future.delayed(milliSeconds.toMilliSeconds)).listen((event) {
    if (mounted) {
      listen(event);
    }
  });
  addStreamSubscription(stream);
  return stream;
}