mirror of
https://gitlab.com/nkming2/nc-photos.git
synced 2025-01-22 16:56:19 +01:00
17 lines
222 B
Dart
17 lines
222 B
Dart
|
class Lazy<T> {
|
||
|
Lazy(this.build);
|
||
|
|
||
|
T call() {
|
||
|
if (build != null) {
|
||
|
_value = build!();
|
||
|
build = null;
|
||
|
}
|
||
|
return _value;
|
||
|
}
|
||
|
|
||
|
T get get => call();
|
||
|
|
||
|
T Function()? build;
|
||
|
late final T _value;
|
||
|
}
|