polarby / render

A package to render any native static and moving flutter widgets to exportable formats
https://pub.dev/packages/render
MIT License
49 stars 26 forks source link

Hide and make widget invisible when using captureMotionWithStream() #22

Closed qiwen98 closed 11 months ago

qiwen98 commented 11 months ago

Hi, thanks for the great work!

Is it possible to hide the Render widget (e.g. the AnimatedExampleWidget in main.dart) when using the captureMotionWithStream, I wish to render and record the widget in the background by not showing the rendering process. CaptureMotionFromWidgetWithStream sounds like the feature I want, but I have no idea how to modify it in main.dart. I would appreciate any help.

polarby commented 11 months ago

Sure. CaptureMotionFromWidgetWithStream has a widget parameter input. This function will provide your widget a off-screen context, from which it is being build.

Thefore you can simply do:

final stream = controller.captureMotionFromWidgetWithStream(AnimatedExampleWidget(), ...);

This code is not written in your widget tree, but you can put it in your initState() for example.

Does this answer your question?

Sagar-KC-3082 commented 4 months ago

I had an animated screen which I wanted to download when the user presses the download button. I tried doing it by captureMotionFromWidgetWithStream(MyAnimatedClass,.....). But this was calling the initState of MyAnimationClass multiple times and wasn't able to render the animation. The video was being saved but it was just a blank screen video.

polarby commented 4 months ago

If you display the animation don't use ...fromWidget. Nonetheless I believe that is an issue in your code. Please try your problem with a default widget and compare if the issue still arises. I am unable to determine what's going wrong just from your text, but you might be required to preload the data in your initstate and then pass it to your to-be-rendered widget.

Sagar-KC-3082 commented 3 months ago

I have to use the animations and render them in background. Using captureMotionFromWidgetWithStream() creates certain issue.. Is there any way I can communicate with you ?? Would be a great help to me.