Repository: flutter
Issue: Suggest adding a new widget or handling Wrap with "isExpandable" flag
Labels: c: new feature,framework,c: proposal,P3,team-framework,triaged-framework

### Use case

I'm building a cross-platform app for courses, including a web version. The design of the app requires the course cards to be arranged in a flexible wrap layout, where the cards can expand to fill the available space and wrap to the next line as needed.

To address this problem, I have developed the "flexible_wrap" package (https://pub.dev/packages/flexible_wrap) as a solution.

### Proposal


![showcase](https://github.com/bixat/flexible_wrap/blob/main/showcase.gif?raw=true)


I've been working on a package called "flexible_wrap" (https://pub.dev/packages/flexible_wrap) that aims to provide a flexible and customizable way to arrange widgets in a wrap layout. The key feature is allowing the widgets to expand according to the available space, similar to how items behave in a shopping cart or a list of cards.

The current implementation of the "flexible_wrap" package uses the existing Flutter 'RenderWrap' Render Object, but I believe there is room for improvement in the core Flutter framework to better handle this use case.

I would like to propose two potential solutions:

1. **Create a new widget:** Add a new widget to the Flutter framework that provides the "expandable wrap" behavior out of the box. This would allow developers to easily create dynamic layouts where widgets can wrap onto the next line and expand to fill the available space.

2. **Add an "isExpandable" flag to the Wrap widget:** Enhance the existing `Wrap` widget by adding an "isExpandable" flag that, when set, would allow the items to expand according to the available space. This would provide more flexibility and control for developers who need this behavior.

The key benefits of these solutions would be:

- Provide a built-in, well-tested, and performant way to create flexible wrap layouts in Flutter applications.
- Reduce the need for third-party packages and custom implementations, making it easier for developers to create these types of layouts.
- Ensure consistency and best practices across the Flutter ecosystem.

I've already explored implementing this functionality in the "flexible_wrap" package, but I believe having it as a core part of the Flutter framework would be more beneficial for the community. I'm happy to discuss this further and provide more details on the implementation and use cases.

Custom Layout Implementation
As part of the "flexible_wrap" package, I've developed a custom RenderBox implementation that extends the RenderWrap class. This implementation provides the core functionality for the flexible wrap layout. Here's a snippet of the code:
```dart
@override
  void performLayout() {
    final BoxConstraints constraints = this.constraints;
    assert(_debugHasNecessaryDirections);
    _hasVisualOverflow = false;
    RenderBox? child = firstChild;
    if (child == null) {
      size = constraints.smallest;
      return;
    }
    double dx = 0.0;
    double dy = 0.0;
    double extraWidth = 0.0;
    int lines = 1;
    final parentWidth = constraints.maxWidth;
    while (child != null) {
      child.layout(constraints, parentUsesSize: true);
      final double itemWidth = child.size.width;
      if (parentWidth.isFinite) {
        final items = (parentWidth / itemWidth).floor();
        double remainder = parentWidth - (itemWidth * items);
        extraWidth = remainder / items;
      }
      final newWidth = extraWidth + itemWidth;
      child.layout(BoxConstraints.tight(Size(newWidth, child.size.height)),
          parentUsesSize: true);
      final WrapParentData childParentData =
          child.parentData! as WrapParentData;
      childParentData.offset = Offset(dx, dy);

      if (dx + newWidth < constraints.maxWidth) {
        dx += newWidth;
      } else {
        dx = 0;
        dy = child.size.height * lines;
        lines++;
      }
      size = constraints.constrain(Size(constraints.maxWidth, dy));
      child = childAfter(child);
    }
  }
```
This custom RenderBox implementation is used to provide the "flexible wrap" behavior in the FlexibleWrap widget, which is the main component of the flexible_wrap package.

Please let me know if you have any questions or thoughts on this proposal. I'm excited to work with the Flutter team to improve the framework and make it easier for developers to create dynamic and responsive layouts