loadShader method

Future<FragmentShader> loadShader(
  1. ShaderMode mode
)

Loads a shader for the given mode. If the shader is already loaded, it returns the cached version. Otherwise, it asynchronously loads and caches the shader.

Implementation

Future<FragmentShader> loadShader(ShaderMode mode) async {
  assert(
    isShaderFilterSupported,
    'Shader filters are not supported on the current backend.',
  );

  if (shaders[mode] != null) return shaders[mode]!;

  _loadingFuture ??= _loadShader(mode);
  await _loadingFuture;

  return shaders[mode]!;
}