Giter VIP home page Giter VIP logo

Comments (5)

lukehutch avatar lukehutch commented on August 25, 2024 1

Correct, I forgot about that, you can introduce BuildContext anywhere you want in that way for efficiency. I don't think there will be significant performance differences most of the time, because rebuilding is fairly lightweight once the Element tree is built. Also it's good style to keep widgets small in terms of tree size.

I'll update the docs.

from flutter_reactive_value.

lukehutch avatar lukehutch commented on August 25, 2024

It's the widget that is the BuildContext passed into reactiveValue that is scheduled to be rebuilt. BuildContext is actually an Element, so technically it's the Element, not the Widget, that is rebuilt -- Element is the laid-out view of a widget. The scheduling happens via Element.markMeedsBuild().

This may trigger other elements to be rebuilt too, especially if the size of the Element changes, since constraints are passed down the Element tree and sizes are passed back up. And of course it will trigger a render frame, which (I assume) will only redraw the area of the screen that was marked for rebuilding, but I'm not sure about that.

I should update the docs to make this clearer, sorry!

from flutter_reactive_value.

lukehutch avatar lukehutch commented on August 25, 2024

Sorry, I reread your question... The Text Widget optimally would be the only one rebuilt, yes. But it has no BuildContext, so there's no way to get a reference to it.

In general you should be breaking large coplex widget trees down into separate widgets, for readability if nothing else, so usually widget trees go only a few layers deep below a BuildContext, and the re-layout should not be horribly wasteful.

from flutter_reactive_value.

AntonEriksson978 avatar AntonEriksson978 commented on August 25, 2024

The Builder widget could provide the parents BuildContext exactly where and when you need it.

from flutter_reactive_value.

lukehutch avatar lukehutch commented on August 25, 2024

@AntonEriksson978 The docs are updated. Thanks for pointing this out, it is an important point!

from flutter_reactive_value.

Related Issues (5)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.