MohamedAbd0 / widgets_to_image

Export your widget to image with flutter
https://pub.dev/packages/widgets_to_image
MIT License
22 stars 7 forks source link

Error thrown on Null Check operator when converting widgets to images #5

Closed ljsharp closed 6 months ago

ljsharp commented 1 year ago

I used this package for printing images using esc/pos thermal printer. A error thrown when trying to convert more than one widgets to images. The error caused by a null value of a variable - boundary in a function - capture() in utils.dart file

Future<Uint8List?> capture() async {
    try {
      /// boundary widget by GlobalKey
      RenderRepaintBoundary? boundary = containerKey.currentContext
          ?.findRenderObject() as RenderRepaintBoundary?;

      /// convert boundary to image
      final image = **await boundary!.toImage(pixelRatio: 6);**

Does a variable get nullified after converting a first widget?

GiulioWecove commented 1 year ago

Same problem here!

MohamedAbd0 commented 6 months ago

I upload the new version to solve this pugs.