nc-photos/np_common/lib/lazy.dart
2023-08-26 01:34:07 +08:00

16 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;
}