文件最后提交记录最后更新时间
[pigeon] reorg generator files (#8532) Just moves a few files into folders to clean things up a bit. Future organizing is likely, but I wanted to move the files with no changes first1 年前
[pigeon] cleaned up gitignore (#352) 4 年前
Fix 'publish' and 'test' failures (#346) Enabling the new publishing checks was done in a PR that touched at least one package, so didn't actually run on the whole repo, causing post-submit breakage. This fixes the publish errors: - Corrects a version mismatch in fuchsia_ctl and standardizes the format it uses for listing recent versions. - Removes all pre-release SDK requirements now that null safety is stable. - Fixes a publish warning about the use of 'docs' rather than 'doc' in pigeon. It also fixes the test in error in bsdiff by reverting #342 and fixing it correctly. That change was completely wrong, but CI didn't catch it since it wasn't running any tests for third_party/packages/ yet.4 年前
[pigeon] Use a const for custom type ids for gobject generated files (#156100) (#9306) Adds a custom type identifier to generated gobject headers for the user. Calling fl_value_new_custom_object is now possible with that constant. This fixes https://github.com/flutter/flutter/issues/156100 ## Pre-Review Checklist [^1]: Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling.11 个月前
[pigeon] Create a message call free InstanceManager when running unit tests (#9395) To support hot restart, PigeonInstanceManager.instance makes a call to clear the native InstanceManager when it is instantiated. This was the source of unit test race condition flakes like https://github.com/flutter/flutter/issues/164132. The current workaround is to try/catch the async PlatformException at the top of every test file or pass a test InstanceManager to every ProxyApi class: ```dart final MyNativeClass object = MyNativeClass( pigeon_instanceManager: PigeonInstanceManager( onWeakReferenceRemoved: (_) {} ), ); ``` This PR changes it to [detect a test ran as Flutter unit test](https://api.flutter.dev/flutter/flutter_test/TestWidgetsFlutterBinding/ensureInitialized.html) and sets the default InstanceManager with one that doesn't make any message calls. ## Pre-Review Checklist [^1]: Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling.11 个月前
[pigeon] adds Internal options (#8709) Separates the user facing options from the internal use of options to avoid exposing settings we don't need the users to access. fixes https://github.com/flutter/flutter/issues/161634 Also adds option to prevent merging of pigeon definition file options. fixes https://github.com/flutter/flutter/issues/163159 Also removes injection of overflow members for testing from public facing api surface.1 年前
[pigeon] Create a message call free InstanceManager when running unit tests (#9395) To support hot restart, PigeonInstanceManager.instance makes a call to clear the native InstanceManager when it is instantiated. This was the source of unit test race condition flakes like https://github.com/flutter/flutter/issues/164132. The current workaround is to try/catch the async PlatformException at the top of every test file or pass a test InstanceManager to every ProxyApi class: ```dart final MyNativeClass object = MyNativeClass( pigeon_instanceManager: PigeonInstanceManager( onWeakReferenceRemoved: (_) {} ), ); ``` This PR changes it to [detect a test ran as Flutter unit test](https://api.flutter.dev/flutter/flutter_test/TestWidgetsFlutterBinding/ensureInitialized.html) and sets the default InstanceManager with one that doesn't make any message calls. ## Pre-Review Checklist [^1]: Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling.11 个月前
[pigeon] Use a const for custom type ids for gobject generated files (#156100) (#9306) Adds a custom type identifier to generated gobject headers for the user. Calling fl_value_new_custom_object is now possible with that constant. This fixes https://github.com/flutter/flutter/issues/156100 ## Pre-Review Checklist [^1]: Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling.11 个月前
[pigeon] Convert test plugins to SPM (#9105) Updates the test harness plugins to support SPM, so that tests won't rely on CocoaPods going forward. For now I've left CocoaPods support in the plugins and the integration in the example app, so that local tests won't rely on SPM support being on, but in the future when needing to disable it locally for testing plugins is rare we can fully remove CocoaPods from the test plugins and their apps since they aren't public plugins and thus don't need to support both modes once we don't use both ourselves. Part of https://github.com/flutter/flutter/issues/146922 ## Pre-Review Checklist [^1]: Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling.1 年前
[pigeon] primitive enums (#4580) Adds support for enums as parameters and return types. Dart, C++, Java, Kotlin, Objective-C, and swift: Primitive synchronous non-null Primitive synchronous nullable Primitive asynchronous non-null Primitive asynchronous nullable Primitive Flutter api non-null Primitive flutter api nullable Objective-C: Class property nullable Also fixes an issue with nullable enums in classes on objc. This fix required a breaking change that nested all nullable enums in a wrapper class to allow nullability. Also adds the ability to format files before tests run (to make my life better) Also replaces https://github.com/flutter/packages/pull/4756 Also adds objc prefixes to enums fixes: https://github.com/flutter/flutter/issues/87307 fixes: https://github.com/flutter/flutter/issues/1187332 年前
Standardize copyright author and year (#338) Standardize copyright author ("The Flutter Authors") and year (2013), as was previously done in flutter/plugins. Adds per-package AUTHORS files to ensure that published packages contain the authorship information referred to in the boilerplate (again, as in flutter/plugins). First preparatory step in enabling the automated license format check in this repository.4 年前
[pigeon] Create a message call free InstanceManager when running unit tests (#9395) To support hot restart, PigeonInstanceManager.instance makes a call to clear the native InstanceManager when it is instantiated. This was the source of unit test race condition flakes like https://github.com/flutter/flutter/issues/164132. The current workaround is to try/catch the async PlatformException at the top of every test file or pass a test InstanceManager to every ProxyApi class: ```dart final MyNativeClass object = MyNativeClass( pigeon_instanceManager: PigeonInstanceManager( onWeakReferenceRemoved: (_) {} ), ); ``` This PR changes it to [detect a test ran as Flutter unit test](https://api.flutter.dev/flutter/flutter_test/TestWidgetsFlutterBinding/ensureInitialized.html) and sets the default InstanceManager with one that doesn't make any message calls. ## Pre-Review Checklist [^1]: Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling.11 个月前
[pigeon] Use a const for custom type ids for gobject generated files (#156100) (#9306) Adds a custom type identifier to generated gobject headers for the user. Calling fl_value_new_custom_object is now possible with that constant. This fixes https://github.com/flutter/flutter/issues/156100 ## Pre-Review Checklist [^1]: Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling.11 个月前
Standardize slight variations in license format (#339) - Uses the exact LICENSE file line breaking used in the other Flutter repositories - Standardizes some slight textual variants in the license block (e.g., use of "(c)", explicitly referencing the AUTHORS file) on the format used in the other repos.4 年前
[pigeon] Discuss stability in README (#8366) Updates the README to discuss two anti-patterns that clients should be aware of: - Why Pigeon-generated code should not be used in public APIs. - Why Pigeon-generated code should not be split across packages.1 年前
[pigeon] added the ability to add a copyright notice to generated files (#377) 4 年前
[ci] Add a web version of Dart unit tests (#4352) Adds new LUCI targets in bringup mode to run all possible Dart unit tests in Chrome. This is a new test (see linked issue), not a port of a Cirrus test, so it involves changes to tooling and packages: - The tooling now accepts an explicit platform. The default behavior if none is provided is the previous behavior of running in VM for everything but web plugin implementations (since that's convenient locally). - The tooling now has a basic understanding of dart_test.yaml test_on directives, to know when to skip. - Packages that don't support web have opt-out files. - Packages that do support web but have a few tests that fail on web have those tests opted out. - Packages that do support web but have a lot of failures on web have temporary opt-out files with TODOs + issue links. Most of https://github.com/flutter/flutter/issues/1289792 年前
[pigeon] added a tool to help with comparing the output of different versions (#390) 4 年前
[pigeon] Create a message call free InstanceManager when running unit tests (#9395) To support hot restart, PigeonInstanceManager.instance makes a call to clear the native InstanceManager when it is instantiated. This was the source of unit test race condition flakes like https://github.com/flutter/flutter/issues/164132. The current workaround is to try/catch the async PlatformException at the top of every test file or pass a test InstanceManager to every ProxyApi class: ```dart final MyNativeClass object = MyNativeClass( pigeon_instanceManager: PigeonInstanceManager( onWeakReferenceRemoved: (_) {} ), ); ``` This PR changes it to [detect a test ran as Flutter unit test](https://api.flutter.dev/flutter/flutter_test/TestWidgetsFlutterBinding/ensureInitialized.html) and sets the default InstanceManager with one that doesn't make any message calls. ## Pre-Review Checklist [^1]: Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling.11 个月前
README.md

Pigeon

Pigeon is a code generator tool to make communication between Flutter and the host platform type-safe, easier, and faster.

Pigeon removes the necessity to manage strings across multiple platforms and languages. It also improves efficiency over common method channel patterns. Most importantly though, it removes the need to write custom platform channel code, since pigeon generates it for you.

For usage examples, see the Example README.

Features

Supported Platforms

Currently pigeon supports generating:

  • Kotlin and Java code for Android
  • Swift and Objective-C code for iOS and macOS
  • C++ code for Windows
  • GObject code for Linux

Supported Datatypes

Pigeon uses the StandardMessageCodec so it supports any datatype platform channels support.

Custom classes, nested datatypes, and enums are also supported.

Basic inheritance with empty sealed parent classes is allowed only in the Swift, Kotlin, and Dart generators.

Nullable enums in Objective-C generated code will be wrapped in a class to allow for nullability.

By default, custom classes in Swift are defined as structs. Structs don't support some features - recursive data, or Objective-C interop. Use the @SwiftClass annotation when defining the class to generate the data as a Swift class instead.

Synchronous and Asynchronous methods

While all calls across platform channel APIs (such as pigeon methods) are asynchronous, pigeon methods can be written on the native side as synchronous methods, to make it simpler to always reply exactly once.

If asynchronous methods are needed, the @async annotation can be used. This will require results or errors to be returned via a provided callback. Example.

Error Handling

Kotlin, Java and Swift

All Host API exceptions are translated into Flutter PlatformException.

  • For synchronous methods, thrown exceptions will be caught and translated.
  • For asynchronous methods, there is no default exception handling; errors should be returned via the provided callback.

To pass custom details into PlatformException for error handling, use FlutterError in your Host API. Example.

For swift, use PigeonError instead of FlutterError when throwing an error. See Example#Swift for more details.

Objective-C and C++

Host API errors can be sent using the provided FlutterError class (translated into PlatformException).

For synchronous methods:

  • Objective-C - Set the error argument to a FlutterError reference.
  • C++ - Return a FlutterError.

For async methods:

  • Return a FlutterError through the provided callback.

Task Queue

When targeting a Flutter version that supports the TaskQueue API the threading model for handling HostApi methods can be selected with the TaskQueue annotation.

Multi-Instance Support

Host and Flutter APIs now support the ability to provide a unique message channel suffix string to the api to allow for multiple instances to be created and operate in parallel.

Usage

  1. Add pigeon as a dev_dependency.
  2. Make a ".dart" file outside of your "lib" directory for defining the communication interface.
  3. Run pigeon on your ".dart" file to generate the required Dart and host-language code: flutter pub get then dart run pigeon with suitable arguments. Example.
  4. Add the generated Dart code to ./lib for compilation.
  5. Implement the host-language code and add it to your build (see below).
  6. Call the generated Dart methods.

Rules for defining your communication interface

Example

  1. The file should contain no method or function definitions, only declarations.
  2. Custom classes used by APIs are defined as classes with fields of the supported datatypes (see the supported Datatypes section).
  3. APIs should be defined as an abstract class with either @HostApi() or @FlutterApi() as metadata. @HostApi() being for procedures that are defined on the host platform and the @FlutterApi() for procedures that are defined in Dart.
  4. Method declarations on the API classes should have arguments and a return value whose types are defined in the file, are supported datatypes, or are void.
  5. Event channels are supported only on the Swift, Kotlin, and Dart generators.
  6. Event channel methods should be wrapped in an abstract class with the metadata @EventChannelApi.
  7. Event channel definitions should not include the Stream return type, just the type that is being streamed.
  8. Objective-C and Swift have special naming conventions that can be utilized with the @ObjCSelector and @SwiftFunction respectively.

Flutter calling into iOS steps

  1. Add the generated Objective-C or Swift code to your Xcode project for compilation (e.g. ios/Runner.xcworkspace or .podspec).
  2. Implement the generated protocol for handling the calls on iOS, set it up as the handler for the messages.

Flutter calling into Android Steps

  1. Add the generated Java or Kotlin code to your ./android/app/src/main/java directory for compilation.
  2. Implement the generated Java or Kotlin interface for handling the calls on Android, set it up as the handler for the messages.

Flutter calling into Windows Steps

  1. Add the generated C++ code to your ./windows directory for compilation, and to your windows/CMakeLists.txt file.
  2. Implement the generated C++ abstract class for handling the calls on Windows, set it up as the handler for the messages.

Flutter calling into macOS steps

  1. Add the generated Objective-C or Swift code to your Xcode project for compilation (e.g. macos/Runner.xcworkspace or .podspec).
  2. Implement the generated protocol for handling the calls on macOS, set it up as the handler for the messages.

Flutter calling into Linux steps

  1. Add the generated GObject code to your ./linux directory for compilation, and to your linux/CMakeLists.txt file.
  2. Implement the generated protocol for handling the calls on Linux, set it up as the vtable for the API object.

Calling into Flutter from the host platform

Pigeon also supports calling in the opposite direction. The steps are similar but reversed. For more information look at the annotation @FlutterApi() which denotes APIs that live in Flutter but are invoked from the host platform. Example.

Stability of generated code

Pigeon is intended to replace direct use of method channels in the internal implementation of plugins and applications. Because the expected use of Pigeon is as an internal implementation detail, its development strongly favors improvements to generated code over consistency with previous generated code, so breaking changes in generated code are common.

As a result, using Pigeon-generated code in public APIs is strongy discouraged, as doing so will likely create situations where you are unable to update to a new version of Pigeon without causing breaking changes for your clients.

Inter-version compatibility

The generated message channel code used for Pigeon communication is an internal implementation detail of Pigeon that is subject to change without warning, and changes to the communication are not considered breaking changes. Both sides of the communication (the Dart code and the host-language code) must be generated with the same version of Pigeon. Using code generated with different versions has undefined behavior, including potentially crashing the application.

This means that Pigeon-generated code should not be split across packages. For example, putting the generated Dart code in a platform interface package and the generated host-language code in a platform implementation package is very likely to cause crashes for some plugin clients after updates.

Feedback

File an issue in flutter/flutter with "[pigeon]" at the start of the title.