loadTexture static method

Future<MapEntry<String, Texture>> loadTexture(
  1. String path,
  2. Uint8List? raw
)

Implementation

static Future<MapEntry<String, Texture>> loadTexture(
    String path, Uint8List? raw) async {
  Uint8List data;
  if (raw != null) {
    data = raw;
  } else {
    final ByteData byteData = await rootBundle.load(path);
    data = byteData.buffer.asUint8List();
  }
  final ui.Codec codec = await ui.instantiateImageCodec(data);
  final ui.FrameInfo frame = await codec.getNextFrame();
  return MapEntry<String, Texture>(path, SubTexture(frame.image));
}