caduandrade / multi_split_view

Provides horizontal or vertical multiple split view for Flutter.
https://caduandrade.github.io/multi_split_view/
MIT License
129 stars 24 forks source link

When setting minimal size and weight, it appears to not function properly。 #46

Closed leavky closed 2 months ago

leavky commented 1 year ago

First of all, thank you very much for creating this package. I want to create three windows, all of which require a minimum width to be set, and I would like the first and third ones to have an initial size set as well.When I set it up, I found that the third window is not displaying properly.

  1. set controller

    final MultiSplitViewController _controller = MultiSplitViewController(areas: [
    Area(weight: 0.1, minimalSize: 150),
    Area(minimalSize: 150),
    Area(weight: 0.1, minimalSize: 150),
    ]);
  2. set children

    final List<Widget> children = [
      Container(
        color: Colors.blue,
        child: const Center(
          child: Text("1"),
        ),
      ),
      Container(
        color: Colors.purple,
        child: const Center(
          child: Text("2"),
        ),
      ),
      Container(
        color: Colors.green,
        child: const Center(
          child: Text("3"),
        ),
      ),
    ];
    
    MultiSplitView multiSplitView = MultiSplitView(
        controller: _controller,
        children: children);
  3. result image

caduandrade commented 1 year ago

Thanks @leavky !

I'll have to review the algorithm. I think maybe it needs to be a little more complex.

Simplifying the current algorithm: 1) Every area will always have a weight even if you don't define it. The component is based on weights. 1.1) In your example the second area was .8. 2) Minimum size is applied area by area after weights are applied given the screen size. 3) When increasing an area because of the minimalSize, this extra weight needs to be removed from the other areas. In this case, it is also removed using the weight (weight of the weight) to maintain proportionality. 4) When removing from other areas, you also need to respect their minimum size! :face_with_spiral_eyes:

I think the problem is occurring at point 4.

leavky commented 1 year ago

I think it would be better to do it this way: 1. Each area can set an initial ratio, but when a minimalSize is set, the ratio can be changed appropriately.

caduandrade commented 3 months ago

Will be resolved by #54

leavky commented 3 months ago

thanks.

caduandrade commented 2 months ago

Better late than never (version 3.0.0) 😬