caduandrade / multi_split_view

Provides horizontal or vertical multiple split view for Flutter.
MIT License
152 stars 29 forks source link

Export DividerWidget and document its purpose #41

Closed klondikedragon closed 1 year ago

klondikedragon commented 1 year ago

Hi @caduandrade see what you think, this could close #40. This mod allowed me to easily add a tooltip for the divider while still using the theme divider painter.

This package is brilliant thank you for contributing this to the community!

caduandrade commented 1 year ago

Hi @klondikedragon!

Thank you for your help!

I was thinking of something more direct to the developer. Maybe the developer doesn't need to know which is the default divider class. I believe that changing the DividerBuilder by adding the default divider could be enough. So the developer could wrap it or ignore returning a new Widget.

Something like this:

typedef DividerBuilder = Widget Function(Axis axis, int index, bool resizable,
    bool dragging, bool highlighted, MultiSplitViewThemeData themeData, Widget divider);
klondikedragon commented 1 year ago

@caduandrade that approach could work too. if the DividerBuilder signature was changed to accept the default divider, then it would always do the work required to build the create the DividerWidget object even if that was thrown away. That's not really a big deal because it's not actually building the widget itself if the widget isn't put into the widget tree (the constructor is just setting a few fields), so maybe it's just a pedantic concern.

Another option to consider would be for the package to expose a default divider builder that would build the default DividerWidget, but without exposing the DividerWidget directly. Something like:

class MultiSplitView extends StatefulWidget {
  static Widget defaultDividerBuilder(Axis axis, int index, bool resizable,
    bool dragging, bool highlighted, MultiSplitViewThemeData themeData) =>
      DividerWidget(
        axis: axis,
        index: index,
        themeData: themeData,
        highlighted: highlighted,
        resizable: widget.resizable,
        dragging: dragging);

Then my code could create a custom DividerBuilder that could call the defaultDividerBuilder to construct the default widget, and wrap it, etc.

What do you think? I'd be totally happy by your proposal above as it's a little more convenient to use for my use case, but it breaks backwards compatibility. I'd be happy to update the PR with whichever direction you'd prefer.

caduandrade commented 1 year ago

Hi @klondikedragon!

I'm so sorry, you can ignore my idea. I realized that the DividerWidget has only the visual effect (painting). All events like click and drag are created by MultiSplitView. So it's harmless to export it.

caduandrade commented 1 year ago

It's late here. Tomorrow I will update the CHANGELOG and maybe create an example in the README. Then release the version ok?

Thanks a lot for your contribution. Anything else just let me know.

klondikedragon commented 1 year ago

@caduandrade -- thank you!!