Repository: flutter
Issue: [pigeon] Implement Swift methods using async & await
Labels: package,c: proposal,team-ecosystem,p: pigeon,P3,triaged-ecosystem

<!-- Thank you for using Flutter!

     If you are looking for support, please check out our documentation
     or consider asking a question on Stack Overflow:
      * https://flutter.dev/
      * https://api.flutter.dev/
      * https://stackoverflow.com/questions/tagged/flutter?sort=frequent

     If you have found a bug or if our documentation doesn't have an answer
     to what you're looking for, then fill out the template below. Please read
     our guide to filing a bug first: https://flutter.dev/docs/resources/bug-reports
-->

## Use case

I would like to be able to write Swift functions using async & await instead of completion handlers. Currently, pigeon generates the protocol class methods with completion handlers, which means the implementation of that method requires the use of completion handlers and throws an `error: type 'CustomClassPlugin' does not conform to protocol 'CustomClassApi'` if you instead implement them using async & await.

## Proposal

<!--
     Briefly but precisely describe what you would like Flutter to be able to do.

     Consider attaching something showing what you are imagining:
      * images
      * videos
      * code samples

     Does this have to be provided by Flutter directly, or can it be provided
     by a package on pub.dev/flutter? If so, maybe consider implementing and
     publishing such a package rather than filing a bug.
-->

Either migrate pigeon to define Swift methods in generated files as using async & await or add some syntax to differentiate if you want a generated method to use completion handlers or async & await.

## Example
Given a pigeon file like this:
```dart
import 'package:pigeon/pigeon.dart';

@HostApi(dartHostTestHandler: 'TestLocalAuthApi')
abstract class LocalAuthApi {
  /// Returns true if this device supports authentication.
  // @async
  // bool isDeviceSupported();

  /// Attempts to authenticate the user with the provided [localizedReason] as
  /// the user-facing explanation for the authorization request.
  ///
  /// Returns true if authorization succeeds, false if it is attempted but is
  /// not successful, and an error if authorization could not be attempted.
  @async
  bool authenticate(String localizedReason);
}
```
I want to be able to implement the authenticate method using async and await like the below:
```swift
    func authenticate(localizedReason: String) async throws -> Bool {
        let context = LAContext()
        Task {
            do {
                let authorized = try await context.evaluatePolicy(.deviceOwnerAuthentication, localizedReason: localizedReason)
                return authorized
            } catch {
                throw error
            }
        }

    }
```
Currently, this throws the error above because the pigeon generated `authenticate` method looks like this:
```swift
/// Generated protocol from Pigeon that represents a handler of messages from Flutter.
protocol LocalAuthApi {
  /// Returns true if this device supports authentication.
  /// Attempts to authenticate the user with the provided [localizedReason] as
  /// the user-facing explanation for the authorization request.
  ///
  /// Returns true if authorization succeeds, false if it is attempted but is
  /// not successful, and an error if authorization could not be attempted.
  func authenticate(localizedReason: String, completion: @escaping (Result<Bool, Error>) -> Void)
}
```