-
Notifications
You must be signed in to change notification settings - Fork 481
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FlareActors inside a TabBar get rebuild #127
Comments
|
I think Flutter rebuilds the view as you swap selected Tab bar. I'd suspect it's doing some kind of virtualizing so it only keeps the widgets that are visible attached to the widget hierarchy. There may be a way to prevent that, but that may come at a performance cost. Is there a visual problem with the rebuild? Take a look at this for a potential way to prevent the rebuild: flutter/flutter#19116 |
You are correct, but I am talking about the actual ps. I am new to flutter, so there might just be some fundamental thing I am missing. |
You could do it with a custom FlareController that doesn't reset animation positions even after reload. You'd just have to make sure the controller outlives the widget. You might still get flashing as it reloads however. Another way to do this is to share the instanced Flare Artboard across different LeafRenderWidgets. This would allow you to be in control of when the Flare file is loaded and when to display it/how to animate it. Take a look at the solution I proposed to this problem: #111 (comment) The concept would be the same, instead of passing a filename to the widget, you'd pass the actual Flare Artboard to render. That way even if the widget detached/re-attaches, it'll reuse the same controller and artboard. The example linked in that comment shows how to do this and implements a custom LeafRenderWidget that does this here: See how it gets used here: |
This seems to have done the trick! Thank you! |
Putting FlareActors inside a TabBar (MaterialApp -> Scaffold -> bottomNavigationBar) causes some of the FlareActors to rebuild (call initialize method).
Steps to reproduce:
Is this expected behavior? And if so, what is the correct approach to stop this from happening.
ps. If you use a custom FlareController you can see that the initialize method gets called. Diggin trough the sourcers I found out that the attach method gets called in flare_render_box.dart file:
The text was updated successfully, but these errors were encountered: