My app does some simple image processing through dart image library. As a result of image processing I has ByteData with pixels. I want display result of image processing as it is (without converting to png or other format). I tried to implement ui.Image and draw it on Canvas, but got a native code error. My code is:
import 'dart:async';
import 'dart:typed_data';
import 'dart:ui' as ui;
import 'package:flutter/material.dart';
class WorkImage implements ui.Image {
final int width;
final int height;
final ByteData byteData;
WorkImage({
this.width,
this.height,
this.byteData,
});
@override
Future<ByteData> toByteData({
ui.ImageByteFormat format = ui.ImageByteFormat.rawRgba
}) {
return Future.value(byteData);
}
@override
void dispose() {
}
}
class ViewPainter extends CustomPainter {
final ui.Image image;
ViewPainter({ this.image });
@override
void paint(Canvas canvas, Size size) {
canvas.drawImage(image, Offset(0, 0), Paint());
}
@override
bool shouldRepaint(CustomPainter oldDelegate) {
return false;
}
}
Error is:
signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x78f Cause: null pointer dereference
Please help me deal with this issue.