File tree Expand file tree Collapse file tree 3 files changed +19
-3
lines changed Expand file tree Collapse file tree 3 files changed +19
-3
lines changed Original file line number Diff line number Diff line change 1
1
2
+ ## 2.4.0
3
+ - Add ` standartProLong ` future extension.
4
+
2
5
## 2.3.0
3
6
- Add more String extensions.
4
7
Original file line number Diff line number Diff line change @@ -5,9 +5,14 @@ import 'package:clock/clock.dart';
5
5
typedef OnTakingTooLongCallback = void Function ();
6
6
7
7
extension FutureExtensions <T > on Future <T > {
8
+ static const standardProlongTimeMs = 300 ;
9
+
8
10
// ignore: comment_references, see https://github.com/dart-lang/linter/issues/2079
9
11
/// If [this] future taking longer than [duration] to execute - [callback] is called.
10
- Future <T > onTakingTooLong (Duration duration, OnTakingTooLongCallback callback) async {
12
+ Future <T > onTakingTooLong (
13
+ Duration duration,
14
+ OnTakingTooLongCallback callback,
15
+ ) async {
11
16
final timer = Timer (duration, callback);
12
17
13
18
try {
@@ -33,9 +38,17 @@ extension FutureExtensions<T> on Future<T> {
33
38
final diff = DateTime .now ().millisecondsSinceEpoch - started;
34
39
35
40
if (diff < duration.inMilliseconds) {
36
- await Future <void >.delayed (Duration (milliseconds: duration.inMilliseconds - diff));
41
+ await Future <void >.delayed (
42
+ Duration (milliseconds: duration.inMilliseconds - diff),
43
+ );
37
44
}
38
45
39
46
return result;
40
47
}
48
+
49
+ Future <T > standardProlong ([int ? milliseconds]) {
50
+ return withMinimalLoadTime (
51
+ Duration (milliseconds: milliseconds ?? standardProlongTimeMs),
52
+ );
53
+ }
41
54
}
Original file line number Diff line number Diff line change 1
1
name : netglade_utils
2
- version : 2.3 .0
2
+ version : 2.4 .0
3
3
description : Dart utils used internally at netglade.
4
4
repository : https://github.com/netglade/flutter_core/tree/main/packages/netglade_utils
5
5
issue_tracker : https://github.com/netglade/flutter_core/issues
You can’t perform that action at this time.
0 commit comments