I’m trying to write some custom graphics stuff, but got stuck at loading shaders.
I have this:
void loadMyShader() async {
var program = await FragmentProgram.fromAsset('shaders/myshader.frag');
}
from the webpage: https://docs.flutter.dev/development/ui/advanced/shaders
in VSCode, but I get an undefined method error for .fromAsset()
The above function definition is inside a simple class.
The only method that gets suggested is .compile(), but that expects some spirv code I don’t know.
Is it an issue with the api being beta, or something completely obvious I’m missing here?
I haven’t compiled the code, I just see the error message described above.
2
Answers
I needed to upgrade flutter. 3.7.7 has it
In your
pubspec.yaml
change the location of where you list your shaders fromassets:
toshaders:
. your final yaml should look like this: