gpuTextureFromAsset function
Implementation
Future<gpu.Texture> gpuTextureFromAsset(String assetPath) async {
// Load resource from the asset bundle. Throws exception if the asset couldn't
// be found in the bundle.
final buffer = await rootBundle.loadBuffer(assetPath);
// Decode the image.
final codec = await ui.instantiateImageCodecFromBuffer(buffer);
final frame = await codec.getNextFrame();
final image = frame.image;
return await gpuTextureFromImage(image);
}