BoxBase.asyncGet would be nice
- Dominant language
- Dart
- Stars
- 4.4k
- Forks
- 449
- PR merge metrics
- No merged PRs in 30d
Description
It would be nice to be able to make the choice between `Box` and `LazyBox` an easy configuration option in an app. That would easier and more elegant if `BoxBase` defined an `asyncGet` method. `Box`'s implementation would just return `Future.value(get(key))`.
This would have saved me this bit of reflective, somewhat fragile code ("fragile" because there might someday be other subtypes of `BoxBase`):
```
BoxBase box = thing passed to us;
Object? cached;
if (box is LazyBox) {
cached = await (box as LazyBox).get(key);
} else {
cached = (box as Box).get(key);
await Future.value(null);
// So that future returned from this method is added to the
// map before method completes
}
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.