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

Assertion error in controller.capture() line #4

Closed HaardikBhagtani closed 1 year ago

HaardikBhagtani commented 1 year ago

Getting below error for this line - Uint8List? bytes = await widget.controller.capture();

[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: 'package:flutter/src/rendering/proxy_box.dart': Failed assertion: line 3453 pos 12: '!debugNeedsPaint': is not true.
E/flutter ( 5923): #0      _AssertionError._doThrowNew (dart:core-patch/errors_patch.dart:51:61)
E/flutter ( 5923): #1      _AssertionError._throwNew (dart:core-patch/errors_patch.dart:40:5)
E/flutter ( 5923): #2      RenderRepaintBoundary.toImage (package:flutter/src/rendering/proxy_box.dart:3453:12)
E/flutter ( 5923): #3      WidgetsToImageController.capture (package:widgets_to_image/src/utils.dart:17:37)
E/flutter ( 5923): #4      PostActionsState.build.<anonymous closure> (package:tethys/views/posts/post_actions.dart:145:64)
E/flutter ( 5923): #5      _InkResponseState.handleTap (package:flutter/src/material/ink_well.dart:1072:21)
E/flutter ( 5923): #6      GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:253:24)
E/flutter ( 5923): #7      TapGestureRecognizer.handleTapUp (package:flutter/src/gestures/tap.dart:627:11)
E/flutter ( 5923): #8      BaseTapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:306:5)
E/flutter ( 5923): #9      BaseTapGestureRecognizer.acceptGesture (package:flutter/src/gestures/tap.dart:276:7)
E/flutter ( 5923): #10     GestureArenaManager.sweep (package:flutter/src/gestures/arena.dart:163:27)
E/flutter ( 5923): #11     GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:464:20)
E/flutter ( 5923): #12     GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:440:22)
E/flutter ( 5923): #13     RendererBinding.dispatchEvent (package:flutter/src/rendering/binding.dart:337:11)
E/flutter ( 5923): #14     GestureBinding._handlePointerEventImmediately (package:flutter/src/gestures/binding.dart:395:7)
E/flutter ( 5923): #15     GestureBinding.handlePointerEvent (package:flutter/src/gestures/binding.dart:357:5)
E/flutter ( 5923): #16     GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:314:7)
E/flutter ( 5923): #17     GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:295:7)
E/flutter ( 5923): #18     _invoke1 (dart:ui/hooks.dart:167:13)
E/flutter ( 5923): #19     PlatformDispatcher._dispatchPointerDataPacket (dart:ui/platform_dispatcher.dart:341:7)
E/flutter ( 5923): #20     _dispatchPointerDataPacket (dart:ui/hooks.dart:94:31)
E/flutter ( 5923): 
MohamedAbd0 commented 1 year ago

can you send your code ?

dzero1 commented 1 year ago

Same happen to me while my capture button inside the "WidgetsToImage". I think this is happen inbetween widget repainting. So I wrap the capture call inside a delayed Future call.

Future.delayed(const Duration(milliseconds: 500), () async{
   final bytes = await controller.capture();
}