Coder Social home page Coder Social logo

Comments (5)

RanfiCD avatar RanfiCD commented on July 26, 2024

Hi!
I've tried to use a DataTable with DiagonalScrollView and assign maxWidth and maxHeight dynamically, considering the size of the DataTable, but I haven't been able to reproduce the issue.

Could you provide a code example to see how you're trying to do it?

Thanks!

from diagonal_scrollview.

rakakhrl avatar rakakhrl commented on July 26, 2024

My code look like this, i use setState to set the max height and max width of the DiagonalScrollView but like i said the getChildSize method always return 0 and since onCreated only called once the value is never change to the current size of the DataTable.

return DiagonalScrollView(
            enableFling: false,
            enableZoom: false,
            maxHeight: childHeight,
            maxWidth: childWidth,
            onCreated: (controller) {
              Size childSize = controller.getChildSize();
              setState(() {
                childHeight = childSize.height;
                childWidth = childSize.width;
              });
            },
            child: DataTable(
              // content load dynamically
            ),
          );

I've just change my code to this because calling setState during build throw error. But still the result of printing the height and width value resulting in 0.

return DiagonalScrollView(
            enableFling: false,
            enableZoom: false,
            // maxHeight: childHeight,
            // maxWidth: childWidth,
            onCreated: (controller) {
              Size childSize = controller.getChildSize();
              print('Height: ${childSize.height}, Width: ${childSize.width}');
            },
            child: DataTable(
              // content load dynamically
            ),
          );

from diagonal_scrollview.

RanfiCD avatar RanfiCD commented on July 26, 2024

I have published a new version. Now onCreated is called after the Widget has been painted.

You should be able to get the right child size and also setState inside onCreated.

Could you try it?

from diagonal_scrollview.

rakakhrl avatar rakakhrl commented on July 26, 2024

Thankyou for the update it's working as expected now the getChildSize method return the correct size of the child widget but there's one problem when calling setState inside onCreated.

In my code i wrap DiagonalScrollView with FutureBuilder to get the data i need for the table, so when i called setState it rerender the whole page including the future builder, so now i'm stuck in a loop.

I can maybe fix this issue on my part by implementing different way of handling state but maybe it would be nice if DiagonalScrollView can set it's own max size internally with the size of it's child? like adding a property called setSizeWithChildSize or something and if it's true then we handle the sizing internally.

Let me know what you think.

from diagonal_scrollview.

RanfiCD avatar RanfiCD commented on July 26, 2024

Glad to hear that the patch works!

The new feature you suggest sounds great, I'll add it soon.

from diagonal_scrollview.

Related Issues (6)

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.