loadTexture static method
Helper function that helps to load textures from assets.
url
assets/images/a.png
Implementation
static Future<TextureInfo> loadTexture(String url) async {
ByteData bytes = await rootBundle.load(url);
// Uint8List imageData = Uint8List.view(bytes.buffer);
var decodedImage = await decodeImageFromList(bytes.buffer.asUint8List());
int imgWidth = decodedImage.width;
int imgHeight = decodedImage.height;
var finalImageData = await decodedImage.toByteData(format: ImageByteFormat.rawRgba);
return TextureInfo(
imgWidth,
imgHeight,
Uint8List.view(finalImageData!.buffer),
);
}