Repository: flutter
Issue: [pigeon] Enhanced enums fields are coalesced into the next class
Labels: package,team-ecosystem,has reproducible steps,p: pigeon,P2,triaged-ecosystem,found in release: 3.27,found in release: 3.28

### What package does this bug report belong to?

pigeon

### What target platforms are you seeing this bug on?

Windows

### Have you already upgraded your packages?

Yes

### Dependency versions

<details><summary>pubspec.lock</summary>

```lock
  pigeon:
    dependency: "direct dev"
    description:
      name: pigeon
      sha256: "6c318e3ef13f52db30ab85ef45b4746ba33b837aeecc549eb8578f78a3dde19a"
      url: "https://pub.dev"
    source: hosted
    version: "22.7.0"
```

</details>


### Steps to reproduce

1. Run `dart pub add --dev pigeon`
2. Ensure that you get Pigeon version `22.7.0`
3. Save the attached `Code Sample` file to `pigeon/temp.dart`
4. Run `dart run pigeon --input pigeon/temp.dart`
5. Observe analysis errors

### Expected results

Since the Pigeon file has an enhanced enum with fields, the Dart output should as well. In other words: 


```dart
enum MyEnum {
  a(1),
  b(2);

  const MyEnum(this.myEnumValue)
  final int myEnumValue; 
}

class MyMessage1 {
  MyMessage1({
    this.field1,
  });

  int? field1;
  // ...
}

class MyMessage2 {
  MyMessage2({
    this.field2,
  });

  int? field2;
  // ...
}
```


### Actual results

Pigeon merges the enhanced enum's field with the preceding class. This is doubly bad if there are two enums with the same named field, as that will cause duplicate field errors in the class. 

```dart
enum MyEnum {
  a,
  b,

  // missing myEnumValue
}

class MyMessage1 {
  MyMessage1({
    this.field1,
    required this.myEnumValue,
  });

  int? field1;

  int myEnumValue;  // <-- This shouldn't be here!

  // ...
}

class MyMessage2 {
  MyMessage2({
    this.field2,
  });

  int? field2;

  // ...
}
```


### Code sample

<details open><summary>Code sample</summary>


```dart
// pigeon/temp.dart
@ConfigurePigeon(PigeonOptions(
  dartOut: 'pigeon/temp.g.dart',
  dartOptions: DartOptions(),
))
library;

import 'package:pigeon/pigeon.dart';

class MyMessage1 {
  int? field1;
}

enum MyEnum {
  a(1),
  b(2);

  final int myEnumValue;
  const MyEnum(this.myEnumValue);
}

class MyMessage2 {
  int? field2;
}
```

</details>


### Screenshots or Videos (None)

<details>
<summary>Screenshots / Video demonstration</summary>

[Upload media here]

</details>


### Logs (None)

<details><summary>Logs</summary>

```console
[Paste your logs here]
```

</details>


### Flutter Doctor output

<details><summary>Doctor output</summary>

```console
[✓] Flutter (Channel stable, 3.27.0, on Microsoft Windows [Version 10.0.26100.2605], locale en-US)
    • Flutter version 3.27.0 on channel stable at C:\Users\Levi\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 8495dee1fd (2 weeks ago), 2024-12-10 14:23:39 -0800
    • Engine revision 83bacfc525
    • Dart version 3.6.0
    • DevTools version 2.40.2

[✓] Windows Version (Installed version of Windows is version 10 or higher)

[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
    • Android SDK at C:\Users\Levi\AppData\Local\Android\sdk
    • Platform android-35, build-tools 35.0.0
    • Java binary at: C:\Program Files\Android\Android Studio\jbr\bin\java
    • Java version OpenJDK Runtime Environment (build 17.0.10+0--11572160)
    • All Android licenses accepted.

[✓] Chrome - develop for the web
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[✓] Visual Studio - develop Windows apps (Visual Studio Build Tools 2022 17.7.1)
    • Visual Studio at C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools
    • Visual Studio Build Tools 2022 version 17.7.34009.444
    • Windows 10 SDK version 10.0.22621.0

[✓] Android Studio (version 2024.2)
    • Android Studio at C:\Program Files\Android\Android Studio
    • 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.10+0--11572160)

[✓] VS Code, 64-bit edition (version 1.95.3)
    • VS Code at C:\Program Files\Microsoft VS Code
    • Flutter extension version 3.102.0

[✓] Connected device (3 available)
    • Windows (desktop) • windows • windows-x64    • Microsoft Windows [Version 10.0.26100.2605]
    • Chrome (web)      • chrome  • web-javascript • Google Chrome 131.0.6778.140
    • Edge (web)        • edge    • web-javascript • Microsoft Edge 131.0.2903.112

[✓] Network resources
    • All expected network resources are available.

• No issues found!
```

</details>