Repository: flutter
Issue: Incorrect use of parent widget error persists even when [Expanded] flex is 0
Labels: framework,c: proposal,a: error message,P3,team-framework,triaged-framework

### Steps to reproduce

Wrap any widget (e.g. Text) with `Expanded` and provide a flex 0. Make sure to make the parent widget a non-flex widget which do not support `Expanded` widgets as a child.

I am encountering this a lot in my flutter web project as I reuse widgets across different viewports so I use `Wrap` or `Row` depending on whether I need to expand the child widget to take the whole screen width. 

I know I can avoid the error I am encountering by putting a condition like if(width < 480) do not wrap with `Expanded` at all but rather I am doing it like this in order to keep the code readable and not repetitive like `flex: width < 480? 0: 1`.

### Expected results

Even though the flex is 0 and the `Expanded` widget is technically doing nothing (I assume), the engine expects the parent widget to be a flex widget - `Column` `Row`.

### Actual results

The logged error is:

```
Incorrect use of ParentDataWidget.
The ParentDataWidget Expanded(flex: 0) wants to apply ParentData of type FlexParentData to a
RenderObject, which has been set up to accept ParentData of incompatible type WrapParentData.
Usually, this means that the Expanded widget has the wrong ancestor RenderObjectWidget. Typically,
Expanded widgets are placed directly inside Flex widgets.
The offending Expanded is currently placed inside a Wrap widget.
```

### Code sample

<details open><summary>Code sample</summary>

```dart
Wrap(
children: [
Expanded(
flex: 0,
child: Text('The expanded widget in this case is doing nothing but flutter still expects a flex parent widget'),
),
],
),
```

</details>


### Screenshots or Video

<details open>
<summary>Screenshots / Video demonstration</summary>

[Upload media here]

</details>


### Logs

<details open><summary>Logs</summary>

```console
Incorrect use of ParentDataWidget.
The ParentDataWidget Expanded(flex: 0) wants to apply ParentData of type FlexParentData to a
RenderObject, which has been set up to accept ParentData of incompatible type WrapParentData.
Usually, this means that the Expanded widget has the wrong ancestor RenderObjectWidget. Typically,
Expanded widgets are placed directly inside Flex widgets.
The offending Expanded is currently placed inside a Wrap widget.
```

</details>


### Flutter Doctor output

<details open><summary>Doctor output</summary>

```console
[✓] Flutter (Channel stable, 3.24.0, on macOS 15.0 24A5331b darwin-arm64, locale en-LB)
    • Flutter version 3.24.0 on channel stable at /Users/hassico/Desktop/Development/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 80c2e84975 (6 weeks ago), 2024-07-30 23:06:49 +0700
    • Engine revision b8800d88be
    • Dart version 3.5.0
    • DevTools version 2.37.2

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
    • Android SDK at /Users/hassico/Library/Android/sdk
    • Platform android-34, build-tools 33.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.11+0-17.0.11b1207.24-11852314)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.4)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 15F31d
    • CocoaPods version 1.15.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2024.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.11+0-17.0.11b1207.24-11852314)

[✓] VS Code (version 1.93.0)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.96.0

[✓] Connected device (3 available)
    • macOS (desktop)                 • macos                 • darwin-arm64   • macOS 15.0 24A5331b darwin-arm64
    • Mac Designed for iPad (desktop) • mac-designed-for-ipad • darwin         • macOS 15.0 24A5331b darwin-arm64
    • Chrome (web)                    • chrome                • web-javascript • Google Chrome 128.0.6613.120
    ! Error: Browsing on the local area network for In English Please Royal Academy . Ensure the device is unlocked and attached with a cable or
      associated with the same local area network as this Mac.
      The device must be opted into Developer Mode to connect wirelessly. (code -27)

[✓] Network resources
    • All expected network resources are available.

• No issues found!
```

</details>