Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Jonah review
  • Loading branch information
bdero committed Dec 13, 2023
commit d7ef71dd670771bd7ed3ca61f8064a3d9c0d11d5
12 changes: 3 additions & 9 deletions lib/gpu/lib/src/shader_library.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ base class ShaderLibrary extends NativeFieldWrapperClass1 {
// Hold a Dart-side reference to shaders in the library as they're wrapped for
// the first time. This prevents the wrapper from getting prematurely
// destroyed.
final Map<String, Shader> shaders_ = {};
final Map<String, Shader?> shaders_ = {};

Shader? operator [](String shaderName) {
// This `flutter_gpu` library isn't always registered as part of the builtin
Expand All @@ -30,14 +30,8 @@ base class ShaderLibrary extends NativeFieldWrapperClass1 {
// Providing a new wrapper to [_getShader] for wrapping the native
// counterpart (if it hasn't been wrapped already) is a hack to work around
// this.
Shader? result = shaders_[shaderName];
if (result == null) {
result = _getShader(shaderName, Shader._());
if (result != null) {
shaders_[shaderName] = result;
}
}
return result;
return shaders_.putIfAbsent(
shaderName, () => _getShader(shaderName, Shader._()));
}

@Native<Handle Function(Handle, Handle)>(
Expand Down