loadShader static method

Future<FragmentProgram> loadShader(
  1. String path, [
  2. String? cacheId
])

Loads a shader program from the given path. If the program is already in the cache, it is returned directly. Otherwise, the program is loaded from the given path and stored in the cache (with the optional cacheId) for future use.

Implementation

static Future<FragmentProgram> loadShader(String path,
    [String? cacheId]) async {
  if (shaderCache.containsKey(cacheId)) {
    return shaderCache[cacheId]!;
  }
  final program = await FragmentProgram.fromAsset(path);
  if (cacheId != null) shaderCache[cacheId] = program;
  return program;
}