of method
The picture of the model at path as it was at modified: null
without a GPU or when the file can't be read as a model.
Implementation
Future<ui.Image?> of(String path, {DateTime? modified}) {
final key = '$path@${modified?.millisecondsSinceEpoch}';
return _pictures.putIfAbsent(key, () {
final done = Completer<ui.Image?>();
// One at a time: each holds the GPU until its frame is back.
_queue = _queue.then((_) async {
ui.Image? image;
try {
final cached = _cacheFile(path, modified);
image = cached != null && cached.existsSync()
? await _decode(await cached.readAsBytes())
: null;
if (image == null) {
image = await _render(path);
if (image != null && cached != null) await _store(cached, image);
}
} on Object catch (error) {
debugPrint(
'just_game_engine_editor: no thumbnail for "$path": $error',
);
}
_done[key] = image;
done.complete(image);
revision.value++;
});
return done.future;
});
}