getImage static method

Future<Image> getImage(
  1. String asset
)

绘制时需要用到 ui.Image 的对象,通过此方法进行转换

Implementation

static Future<ui.Image> getImage(String asset) async {
  ByteData data = await rootBundle.load("packages/flutter_weather_bg_null_safety/$asset");
  Codec codec = await ui.instantiateImageCodec(data.buffer.asUint8List());
  FrameInfo fi = await codec.getNextFrame();
  return fi.image;
}