ShaderRegistry class
Singleton cache of compiled ui.FragmentProgram instances.
Call preload once at app startup (before runApp) to compile all shaders. This prevents jank on the first transition because GPU shader compilation is deferred until the program is first used.
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await ShaderRegistry.instance.preload();
runApp(const MyApp());
}
Properties
Methods
-
createShader(
String key) → FragmentShader? -
Creates a fresh ui.FragmentShader from the cached program for
key. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
preload(
) → Future< void> - Compiles and caches all shader programs.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
- instance → ShaderRegistry
-
The global singleton instance.
final