Repository: flutter
Issue: [pigeon] C++ generator creates code that doesn't compile if a class is used above its declaration in the Dart definition file.
Labels: platform-windows,package,team-ecosystem,p: pigeon,P2,workaround available,triaged-ecosystem

### Is there an existing issue for this?

- [X] I have searched the [existing issues](https://github.com/flutter/flutter/issues)
- [X] I have read the [guide to filing a bug](https://flutter.dev/docs/resources/bug-reports)

### Steps to reproduce

1. Setup your project to use Windows
2. Setup types like this:
```
class PigeonActionCodeInfo {
  const PigeonActionCodeInfo({
    required this.operation,
    required this.data,
  });

  final ActionCodeInfoOperation operation;
  final PigeonActionCodeInfoData data;
}

/// The type of operation that generated the action code from calling
/// [checkActionCode].
enum ActionCodeInfoOperation {
  /// Unknown operation.
  unknown,

  /// Password reset code generated via [sendPasswordResetEmail].
  passwordReset,

  /// Email verification code generated via [User.sendEmailVerification].
  verifyEmail,

  /// Email change revocation code generated via [User.updateEmail].
  recoverEmail,

  /// Email sign in code generated via [sendSignInLinkToEmail].
  emailSignIn,

  /// Verify and change email code generated via [User.verifyBeforeUpdateEmail].
  verifyAndChangeEmail,

  /// Action code for reverting second factor addition.
  revertSecondFactorAddition,
}

class PigeonActionCodeInfoData {
  const PigeonActionCodeInfoData({
    this.email,
    this.previousEmail,
  });

  final String? email;
  final String? previousEmail;
}
``` 
3. Setup your Host API:
```
@HostApi(dartHostTestHandler: 'TestFirebaseAuthHostApi')
abstract class FirebaseAuthHostApi {
  @async
  PigeonActionCodeInfo checkActionCode(
    String code,
  );
}
```

4. Generate the C++ code and integrate it into your Windows plugin, you'll get the error.

### Expected results

Being able to have this kind of return object.

### Actual results

Logs
```
C:\Users\guill\Developer\flutterfire\packages\firebase_auth\firebase_auth\example\windows\flutter\ephemeral\.plugin_symlinks\firebase_auth\windows\messages.g.h(124,32): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int [C:\Users\guill\Developer\flutterfire\packages\firebase_auth\firebase_auth\example\build\windows\plugins\firebase_auth\firebase_auth_plugin.vcxproj]       
C:\Users\guill\Developer\flutterfire\packages\firebase_auth\firebase_auth\example\windows\flutter\ephemeral\.plugin_symlinks\firebase_auth\windows\messages.g.h(126,35): error C2143: syntax error: missing ',' before '&' [C:\Users\guill\Developer\flutterfire\packages\firebase_auth\firebase_auth\example\build\windows\plugins\firebase_auth\firebase_auth_plugin.vcxproj]
C:\Users\guill\Developer\flutterfire\packages\firebase_auth\firebase_auth\example\windows\flutter\ephemeral\.plugin_symlinks\firebase_auth\windows\messages.g.h(131,33): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int [C:\Users\guill\Developer\flutterfire\packages\firebase_auth\firebase_auth\example\build\windows\plugins\firebase_auth\firebase_auth_plugin.vcxproj]       
C:\Users\guill\Developer\flutterfire\packages\firebase_auth\firebase_auth\example\windows\flutter\ephemeral\.plugin_symlinks\firebase_auth\windows\messages.g.h(131,33): error C2143: syntax error: missing ';' before '&' [C:\Users\guill\Developer\flutterfire\packages\firebase_auth\firebase_auth\example\build\windows\plugins\firebase_auth\firebase_auth_plugin.vcxproj]
C:\Users\guill\Developer\flutterfire\packages\firebase_auth\firebase_auth\example\windows\flutter\ephemeral\.plugin_symlinks\firebase_auth\windows\messages.g.h(131,47): error C2238: unexpected token(s) preceding ';' [C:\Users\guill\Developer\flutterfire\packages\firebase_auth\firebase_auth\example\build\windows\plugins\firebase_auth\firebase_auth_plugin.vcxproj]
C:\Users\guill\Developer\flutterfire\packages\firebase_auth\firebase_auth\example\windows\flutter\ephemeral\.plugin_symlinks\firebase_auth\windows\messages.g.h(132,47): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int [C:\Users\guill\Developer\flutterfire\packages\firebase_auth\firebase_auth\example\build\windows\plugins\firebase_auth\firebase_auth_plugin.vcxproj]       
C:\Users\guill\Developer\flutterfire\packages\firebase_auth\firebase_auth\example\windows\flutter\ephemeral\.plugin_symlinks\firebase_auth\windows\messages.g.h(132,47): error C2143: syntax error: missing ',' before '&' [C:\Users\guill\Developer\flutterfire\packages\firebase_auth\firebase_auth\example\build\windows\plugins\firebase_auth\firebase_auth_plugin.vcxproj]
C:\Users\guill\Developer\flutterfire\packages\firebase_auth\firebase_auth\example\windows\flutter\ephemeral\.plugin_symlinks\firebase_auth\windows\messages.g.h(147,28): error C3646: 'data_': unknown override specifier [C:\Users\guill\Developer\flutterfire\packages\firebase_auth\firebase_auth\example\build\windows\plugins\firebase_auth\firebase_auth_plugin.vcxproj]
C:\Users\guill\Developer\flutterfire\packages\firebase_auth\firebase_auth\example\windows\flutter\ephemeral\.plugin_symlinks\firebase_auth\windows\messages.g.h(147,33): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int [C:\Users\guill\Developer\flutterfire\packages\firebase_auth\firebase_auth\example\build\windows\plugins\firebase_auth\firebase_auth_plugin.vcxproj]       
C:\Users\guill\Developer\flutterfire\packages\firebase_auth\firebase_auth\example\windows\flutter\ephemeral\.plugin_symlinks\firebase_auth\windows\messages.g.h(124,32): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int [C:\Users\guill\Developer\flutterfire\packages\firebase_auth\firebase_auth\example\build\windows\plugins\firebase_auth\firebase_auth_plugin.vcxproj]       
C:\Users\guill\Developer\flutterfire\packages\firebase_auth\firebase_auth\example\windows\flutter\ephemeral\.plugin_symlinks\firebase_auth\windows\messages.g.h(126,35): error C2143: syntax error: missing ',' before '&' [C:\Users\guill\Developer\flutterfire\packages\firebase_auth\firebase_auth\example\build\windows\plugins\firebase_auth\firebase_auth_plugin.vcxproj]
C:\Users\guill\Developer\flutterfire\packages\firebase_auth\firebase_auth\example\windows\flutter\ephemeral\.plugin_symlinks\firebase_auth\windows\messages.g.h(131,33): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int [C:\Users\guill\Developer\flutterfire\packages\firebase_auth\firebase_auth\example\build\windows\plugins\firebase_auth\firebase_auth_plugin.vcxproj]       
C:\Users\guill\Developer\flutterfire\packages\firebase_auth\firebase_auth\example\windows\flutter\ephemeral\.plugin_symlinks\firebase_auth\windows\messages.g.h(131,33): error C2143: syntax error: missing ';' before '&' [C:\Users\guill\Developer\flutterfire\packages\firebase_auth\firebase_auth\example\build\windows\plugins\firebase_auth\firebase_auth_plugin.vcxproj]
C:\Users\guill\Developer\flutterfire\packages\firebase_auth\firebase_auth\example\windows\flutter\ephemeral\.plugin_symlinks\firebase_auth\windows\messages.g.h(131,47): error C2238: unexpected token(s) preceding ';' [C:\Users\guill\Developer\flutterfire\packages\firebase_auth\firebase_auth\example\build\windows\plugins\firebase_auth\firebase_auth_plugin.vcxproj]
C:\Users\guill\Developer\flutterfire\packages\firebase_auth\firebase_auth\example\windows\flutter\ephemeral\.plugin_symlinks\firebase_auth\windows\messages.g.h(132,47): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int [C:\Users\guill\Developer\flutterfire\packages\firebase_auth\firebase_auth\example\build\windows\plugins\firebase_auth\firebase_auth_plugin.vcxproj]       
C:\Users\guill\Developer\flutterfire\packages\firebase_auth\firebase_auth\example\windows\flutter\ephemeral\.plugin_symlinks\firebase_auth\windows\messages.g.h(132,47): error C2143: syntax error: missing ',' before '&' [C:\Users\guill\Developer\flutterfire\packages\firebase_auth\firebase_auth\example\build\windows\plugins\firebase_auth\firebase_auth_plugin.vcxproj]
C:\Users\guill\Developer\flutterfire\packages\firebase_auth\firebase_auth\example\windows\flutter\ephemeral\.plugin_symlinks\firebase_auth\windows\messages.g.h(147,28): error C3646: 'data_': unknown override specifier [C:\Users\guill\Developer\flutterfire\packages\firebase_auth\firebase_auth\example\build\windows\plugins\firebase_auth\firebase_auth_plugin.vcxproj]
C:\Users\guill\Developer\flutterfire\packages\firebase_auth\firebase_auth\example\windows\flutter\ephemeral\.plugin_symlinks\firebase_auth\windows\messages.g.h(147,33): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int [C:\Users\guill\Developer\flutterfire\packages\firebase_auth\firebase_auth\example\build\windows\plugins\firebase_auth\firebase_auth_plugin.vcxproj]       
C:\Users\guill\Developer\flutterfire\packages\firebase_auth\firebase_auth\example\windows\flutter\ephemeral\.plugin_symlinks\firebase_auth\windows\messages.g.cpp(82,33): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int [C:\Users\guill\Developer\flutterfire\packages\firebase_auth\firebase_auth\example\build\windows\plugins\firebase_auth\firebase_auth_plugin.vcxproj]      
C:\Users\guill\Developer\flutterfire\packages\firebase_auth\firebase_auth\example\windows\flutter\ephemeral\.plugin_symlinks\firebase_auth\windows\messages.g.cpp(82,33): error C2143: syntax error: missing ',' before '&' [C:\Users\guill\Developer\flutterfire\packages\firebase_auth\firebase_auth\example\build\windows\plugins\firebase_auth\firebase_auth_plugin.vcxproj]
C:\Users\guill\Developer\flutterfire\packages\firebase_auth\firebase_auth\example\windows\flutter\ephemeral\.plugin_symlinks\firebase_auth\windows\messages.g.cpp(84,11): error C2065: 'data': undeclared identifier [C:\Users\guill\Developer\flutterfire\packages\firebase_auth\firebase_auth\example\build\windows\plugins\firebase_auth\firebase_auth_plugin.vcxproj]
C:\Users\guill\Developer\flutterfire\packages\firebase_auth\firebase_auth\example\windows\flutter\ephemeral\.plugin_symlinks\firebase_auth\windows\messages.g.cpp(84,17): error C2789: 'firebase_auth_windows::PigeonActionCodeInfo::PigeonActionCodeInfoData': an object of const-qualified type must be initialized [C:\Users\guill\Developer\flutterfire\packages\firebase_auth\firebase_auth\example\build\windows\plugins\firebase_auth\firebase_auth_plugin.vcxproj]
C:\Users\guill\Developer\flutterfire\packages\firebase_auth\firebase_auth\example\windows\flutter\ephemeral\.plugin_symlinks\firebase_auth\windows\messages.g.cpp(84,5): error C2614: 'firebase_auth_windows::PigeonActionCodeInfo': illegal member initialization: 'data_' is not a base or member [C:\Users\guill\Developer\flutterfire\packages\firebase_auth\firebase_auth\example\build\windows\plugins\firebase_auth\firebase_auth_plugin.vcxproj]
C:\Users\guill\Developer\flutterfire\packages\firebase_auth\firebase_auth\example\windows\flutter\ephemeral\.plugin_symlinks\firebase_auth\windows\messages.g.cpp(95,55): error C2039: 'data': is not a member of 'firebase_auth_windows::PigeonActionCodeInfo' [C:\Users\guill\Developer\flutterfire\packages\firebase_auth\firebase_auth\example\build\windows\plugins\firebase_auth\firebase_auth_plugin.vcxproj]
C:\Users\guill\Developer\flutterfire\packages\firebase_auth\firebase_auth\example\windows\flutter\ephemeral\.plugin_symlinks\firebase_auth\windows\messages.g.cpp(95,68): error C2270: 'data': modifiers not allowed on nonmember functions [C:\Users\guill\Developer\flutterfire\packages\firebase_auth\firebase_auth\example\build\windows\plugins\firebase_auth\firebase_auth_plugin.vcxproj]
C:\Users\guill\Developer\flutterfire\packages\firebase_auth\firebase_auth\example\windows\flutter\ephemeral\.plugin_symlinks\firebase_auth\windows\messages.g.cpp(96,10): error C2065: 'data_': undeclared identifier [C:\Users\guill\Developer\flutterfire\packages\firebase_auth\firebase_auth\example\build\windows\plugins\firebase_auth\firebase_auth_plugin.vcxproj]
C:\Users\guill\Developer\flutterfire\packages\firebase_auth\firebase_auth\example\windows\flutter\ephemeral\.plugin_symlinks\firebase_auth\windows\messages.g.cpp(99,67): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int [C:\Users\guill\Developer\flutterfire\packages\firebase_auth\firebase_auth\example\build\windows\plugins\firebase_auth\firebase_auth_plugin.vcxproj]      
C:\Users\guill\Developer\flutterfire\packages\firebase_auth\firebase_auth\example\windows\flutter\ephemeral\.plugin_symlinks\firebase_auth\windows\messages.g.cpp(99,67): error C2143: syntax error: missing ',' before '&' [C:\Users\guill\Developer\flutterfire\packages\firebase_auth\firebase_auth\example\build\windows\plugins\firebase_auth\firebase_auth_plugin.vcxproj]
C:\Users\guill\Developer\flutterfire\packages\firebase_auth\firebase_auth\example\windows\flutter\ephemeral\.plugin_symlinks\firebase_auth\windows\messages.g.cpp(99,43): warning C4458: declaration of 'PigeonActionCodeInfoData' hides class member [C:\Users\guill\Developer\flutterfire\packages\firebase_auth\firebase_auth\example\build\windows\plugins\firebase_auth\firebase_auth_plugin.vcxproj]
C:\Users\guill\Developer\flutterfire\packages\firebase_auth\firebase_auth\example\windows\flutter\ephemeral\.plugin_symlinks\firebase_auth\windows\messages.g.cpp(100,3): error C2065: 'data_': undeclared identifier [C:\Users\guill\Developer\flutterfire\packages\firebase_auth\firebase_auth\example\build\windows\plugins\firebase_auth\firebase_auth_plugin.vcxproj]
C:\Users\guill\Developer\flutterfire\packages\firebase_auth\firebase_auth\example\windows\flutter\ephemeral\.plugin_symlinks\firebase_auth\windows\messages.g.cpp(100,11): error C2065: 'value_arg': undeclared identifier [C:\Users\guill\Developer\flutterfire\packages\firebase_auth\firebase_auth\example\build\windows\plugins\firebase_auth\firebase_auth_plugin.vcxproj]
C:\Users\guill\Developer\flutterfire\packages\firebase_auth\firebase_auth\example\windows\flutter\ephemeral\.plugin_symlinks\firebase_auth\windows\messages.g.cpp(108,33): error C2065: 'data_': undeclared identifier [C:\Users\guill\Developer\flutterfire\packages\firebase_auth\firebase_auth\example\build\windows\plugins\firebase_auth\firebase_auth_plugin.vcxproj]
C:\Users\guill\Developer\flutterfire\packages\firebase_auth\firebase_auth\example\windows\flutter\ephemeral\.plugin_symlinks\firebase_auth\windows\messages.g.cpp(113,31): error C2665: 'firebase_auth_windows::PigeonActionCodeInfo::PigeonActionCodeInfo': no overloaded function could convert all the argument types [C:\Users\guill\Developer\flutterfire\packages\firebase_auth\firebase_auth\example\build\windows\plugins\firebase_auth\firebase_auth_plugin.vcxproj]
```

### Code sample

<details><summary>Code sample</summary>

```dart
class PigeonActionCodeInfo {
  const PigeonActionCodeInfo({
    required this.operation,
    required this.data,
  });

  final ActionCodeInfoOperation operation;
  final PigeonActionCodeInfoData data;
}

/// The type of operation that generated the action code from calling
/// [checkActionCode].
enum ActionCodeInfoOperation {
  /// Unknown operation.
  unknown,

  /// Password reset code generated via [sendPasswordResetEmail].
  passwordReset,

  /// Email verification code generated via [User.sendEmailVerification].
  verifyEmail,

  /// Email change revocation code generated via [User.updateEmail].
  recoverEmail,

  /// Email sign in code generated via [sendSignInLinkToEmail].
  emailSignIn,

  /// Verify and change email code generated via [User.verifyBeforeUpdateEmail].
  verifyAndChangeEmail,

  /// Action code for reverting second factor addition.
  revertSecondFactorAddition,
}

class PigeonActionCodeInfoData {
  const PigeonActionCodeInfoData({
    this.email,
    this.previousEmail,
  });

  final String? email;
  final String? previousEmail;
}

@HostApi(dartHostTestHandler: 'TestFirebaseAuthHostApi')
abstract class FirebaseAuthHostApi {
  @async
  PigeonActionCodeInfo checkActionCode(
    String code,
  );
}
```

</details>


### Screenshots or Video

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


### Logs

<details><summary>Logs</summary>

```console
[Paste your logs here]
```

</details>


### Flutter Doctor output

<details><summary>Doctor output</summary>

```console
[√] Flutter (Channel stable, 3.10.1, on Microsoft Windows [Version 10.0.22621.1702], locale en-150)
[√] Windows Version (Installed version of Windows is version 10 or higher)
[!] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    X cmdline-tools component is missing
      Run `path/to/sdkmanager --install "cmdline-tools;latest"`
      See https://developer.android.com/studio/command-line for more details.
    X Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/docs/get-started/install/windows#android-setup for more details.
[√] Chrome - develop for the web
[√] Visual Studio - develop for Windows (Visual Studio Community 2022 17.5.1)
[√] Android Studio (version 4.1)
[√] VS Code (version 1.78.2)
[√] Connected device (3 available)
[√] Network resources```

</details>