esc_pos_printer icon indicating copy to clipboard operation
esc_pos_printer copied to clipboard

Cannot print Image - The getter 'width' was called on null

Open xSuperMu opened this issue 3 years ago • 0 comments

I'm using: printer: EPSON TM-m30 esc_pos_printer: ^4.0.3

I'm trying to print an image using the following code:

import 'package:image/image.dart' as im;

final ByteData data = await image.toByteData();
Uint8List preImage = data.buffer.asUint8List();
im.Image img = im.decodeImage(preImage);
printer.image(img);

and it causes this error:

 Unhandled Exception: NoSuchMethodError: The getter 'width' was called on null.

I've tried to do the following:

import 'package:image/image.dart' as im;


final ByteData data = await image.toByteData();
Uint8List preImage = data.buffer.asUint8List();
im.Image img = im.decodeImage(preImage);
im.Image thumbnail = im.copyResize(img, width: 80);
printer.image(thumbnail);

and still causes the same error.

xSuperMu avatar Feb 28 '21 13:02 xSuperMu