reinitialize static method
- String assetKey
Re-fetches assetKey through the asset manager and reparses it into
the cached ShaderLibrary for that key, marking each shader dirty so
the next pipeline build evicts and re-registers it. The primary caller
is the ext.ui.gpu.reinitializeShaderLibrary service extension driving
hot reload from flutter_tools; tests may also call this directly.
No-ops if no library has been loaded for assetKey.
assetKey must be the asset's bundle path: the same string passed to
fromAsset and listed in the asset manifest. That path is both the
registry key here and the value flutter_tools dispatches, so the two
must match for a reload to land.
Implementation
static void reinitialize(String assetKey) {
final ShaderLibrary? lib = _registry[assetKey];
if (lib == null) {
// No library for this asset is loaded yet; the next `fromAsset` call
// will pick up the fresh bytes on its own.
return;
}
final String? error = lib._reinitializeWithAsset(assetKey);
if (error != null) {
throw Exception("Failed to reinitialize ShaderLibrary: ${error}");
}
}