I am using
import 'package:flutter_sunmi_printer/flutter_sunmi_printer.dart';
to print on a sunmi v2 printer. Printing strings and texts works fine:
SunmiPrinter.text(
'Date: ' + DateConverter.dateTimeStringToDateTime(_order.createdAt),
styles: SunmiStyles(align: SunmiAlign.left, size: SunmiSize.md),
);
SunmiPrinter.emptyLines(1);
But, I have a product that I want to print. The product is build like this:
ListView.builder(
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
itemCount: orderController.orderDetailsModel.length,
itemBuilder: (context, index) {
return OrderProductWidget(order: _order, orderDetails: orderController.orderDetailsModel[index]);
How can I print the output of that listview widget? The sunmi library expects either string or image. I tried making it an image first and then print the image but it doesn't like the format of the image. Any ideas?
Thanks!
I tried making it a screenshot image first but it does not seem to work:
Screenshot(
controller: screenshotController,
child:
ListView.builder(
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
itemCount: orderController.orderDetailsModel.length,
itemBuilder: (context, index) {
return OrderProductWidget(order: _order, orderDetails: orderController.orderDetailsModel[index]);
},
),
);
screenshotController.capture().then((Uint8List image) {
//Capture Done
setState(() {
_imageFile = image;
});
}).catchError((onError) {
print(onError);
});
ByteData bytes = await rootBundle.load(_imageFile);
final buffer = bytes.buffer;
final imgData = base64.encode(Uint8List.view(buffer));
SunmiPrinter.image(imgData);