caduandrade / multi_split_view

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

Add a copyWith() method in Area #88

Closed The4Summers closed 2 months ago

The4Summers commented 2 months ago

For the moment, if we want to change some attributes of an Area, we need to create a new one using same id and configuring the attributes we want to change.

In your example:

dynamic oldId1 = _controller.areas[0].id;
dynamic oldId2 = _controller.areas[1].id;
_controller.areas = [
  Area(id: oldId1, flex: 1, builder: (c, a) => Container()),
  Area(id: oldId2, flex: 2, builder: (c, a) => Container())
];

With a copyWith() method it would have been more elegant and less verbose I think, especially when we just want to change one value such as the flex or min soze for examples:

_controller.areas = [
  _controller.areas[0].copyWith(flex: 1),
  _controller.areas[1].copyWith(flex: 2),
];

Or maybe simple setters would have been easier that having to recreate new areas?

proteye commented 2 months ago

@The4Summers Hello. I've added this functionality to a new package created from this. https://pub.dev/packages/multi_split_view_next

caduandrade commented 2 months ago

@The4Summers,

It will be available in version 3.3.0. Thanks.