Fix connection info
This commit is contained in:
16
lib/core/utils/throttler.dart
Normal file
16
lib/core/utils/throttler.dart
Normal file
@@ -0,0 +1,16 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
|
||||
class Throttler {
|
||||
Throttler(this.throttleFor);
|
||||
|
||||
final Duration throttleFor;
|
||||
DateTime? _lastCall;
|
||||
|
||||
void call(VoidCallback callback) {
|
||||
if (_lastCall == null ||
|
||||
DateTime.now().difference(_lastCall!) > throttleFor) {
|
||||
callback();
|
||||
_lastCall = DateTime.now();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user