preload static method

Future<void> preload()

Pre-compiles the blur shader so the first bar paint already has it. Safe to call repeatedly (compiled once). Call from main() after the binding is initialized. Never throws — on failure the widget falls back to a uniform blur.

Implementation

static Future<void> preload() async {
  if (_program != null) return;
  // Package-qualified asset path (this shader ships with the package); the
  // bare path is the fallback for unit tests where the package prefix may not
  // resolve.
  const path =
      'packages/flutter_liquid_glass_widgets/shaders/progressive_blur.frag';
  const testPath = 'shaders/progressive_blur.frag';
  try {
    _program = await (_loading ??= _loadProgram(path, testPath));
  } catch (e) {
    // Graceful degradation: the widget falls back to a uniform blur. (Also the
    // path taken in unit tests, where compiled shaders aren't bundled.)
    _loading = null;
    debugPrint(
      'progressive_blur.frag load failed, using uniform-blur fallback: $e',
    );
  }
}