load static method
Loads the shader. Safe to call any number of times; after a failure, the next call tries again.
Implementation
static Future<ui.FragmentProgram?> load() {
if (_program != null) return Future<ui.FragmentProgram?>.value(_program);
return _loading ??= Future.wait<Object>([_fromAssets(), _decodeEmpty()]).then(
(loaded) {
final program = loaded[0] as ui.FragmentProgram;
_empty ??= loaded[1] as ui.Image;
_program = program;
_error = null;
ready.value = true;
return program;
},
onError: (Object error, StackTrace stack) {
_error = error;
_loading = null;
FlutterError.reportError(
FlutterErrorDetails(
exception: error,
stack: stack,
library: 'glisse_flutter',
context: ErrorDescription('while loading the Liquid Glass shader'),
),
);
return null;
},
);
}