GithubHelp home page GithubHelp logo

Comments (4)

pingbird avatar pingbird commented on August 29, 2024 1

Apologies if the docs are insufficient but the shouldRelayout and shouldRepaint methods are used in the same manner as CustomPainer.shouldRepaint, to compare custom properties that you have added to the constructor of the delegate:

class _TreeViewBoxy extends BoxyDelegate {
  _TreeViewBoxy({
    required this.root,
    required this.verticalSpacing,
    required this.horizontalSpacing,
  });

  ...

  @override
  bool shouldRelayout(_TreeViewBoxy oldDelegate) =>
      root != oldDelegate.root ||
          verticalSpacing != oldDelegate.verticalSpacing ||
          horizontalSpacing != oldDelegate.horizontalSpacing;
}

If your delegate has no parameters then there is no reason to implement the method.

If you want your boxy to relayout based on something other than it's own properties changing or constraints changing or a child updating, you'll probably need to use a notifier of some sort.

from boxy.

WasserEsser avatar WasserEsser commented on August 29, 2024 1

Ah, I see, that makes sense. Thanks for clarifying!

from boxy.

pingbird avatar pingbird commented on August 29, 2024

if the children are updated in any way the boxy will be laid out automatically, the error you are getting is from accessing the old delegate's children from outside of its lifecycle

from boxy.

WasserEsser avatar WasserEsser commented on August 29, 2024

It sounds like I don't need to override the shouldRelayout function at all then.

But I don't understand how the error message is correct because all I'm doing is overriding the method (which, according to the error message should be the correct way). It's also already throwing an exception just accessing the boxy's current children, before trying to access the old delegate's children. It appears as though the shouldRelayout function (which I'm not calling myself) is being called outside of the boxy's lifecycle? Is that an error on my part? Because I don't see how I could influence this in any way. If not, it appears as though you just can't access any property of the boxy delegate or the old delegate in the shouldRelayout function, which makes the whole function pointless to override.

from boxy.

Related Issues (20)

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.