画像を Uint8List にエンコードしようとしていますが、null が返されます
List<int> bytes;
I.Image _img;
@override
void initState() {
super.initState();
WidgetsFlutterBinding.ensureInitialized();
String file = 'lib/graphics/logo.png';
readFileAsync(file);
}
Future<dynamic> readFileAsync(String filePath) async {
var imageData = await rootBundle.load('lib/graphics/logo.png');
bytes = Uint8List.view(imageData.buffer);
_img = I.decodeImage(bytes);
}
ウィジェットツリーから呼び出す
Container(
child: Image.memory(_img.getBytes()),
),
エラー
I/flutter (26125): ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
I/flutter (26125): The following NoSuchMethodError was thrown building LayoutBuilder:
I/flutter (26125): The method 'getBytes' was called on null.
I/flutter (26125): Receiver: null
I/flutter (26125): Tried calling: getBytes()