mirror of
https://github.com/flutter/packages.git
synced 2025-06-30 23:03:11 +08:00
[pigeon] updated readme and made version 0.2.2 (#372)
This commit is contained in:
@ -1,3 +1,7 @@
|
||||
## 0.2.2
|
||||
|
||||
* Added support for enums.
|
||||
|
||||
## 0.2.1
|
||||
|
||||
* Java: Fixed issue where multiple async HostApis can generate multiple Result interfaces.
|
||||
|
@ -70,7 +70,9 @@ Nested data-types are supported, too.
|
||||
|
||||
Note: Generics for List and Map aren't supported yet.
|
||||
|
||||
## Asynchronous Handlers
|
||||
## Features
|
||||
|
||||
### Asynchronous Handlers
|
||||
|
||||
By default Pigeon will generate synchronous handlers for messages. If you want
|
||||
to be able to respond to a message asynchronously you can use the `@async`
|
||||
@ -112,7 +114,7 @@ public interface Api2Host {
|
||||
}
|
||||
```
|
||||
|
||||
## Null Safety (NNBD)
|
||||
### Null Safety (NNBD)
|
||||
|
||||
Right now Pigeon supports generating null-safe code, but it doesn't yet support
|
||||
[non-null fields](https://github.com/flutter/flutter/issues/59118).
|
||||
@ -121,6 +123,57 @@ The default is to generate null-safe code but in order to generate non-null-safe
|
||||
code run Pigeon with the extra argument `--no-dart_null_safety`. For example:
|
||||
`flutter pub run pigeon --input ./pigeons/messages.dart --no-dart_null_safety --dart_out stdout`.
|
||||
|
||||
### Enums
|
||||
|
||||
As of version 0.2.2 Pigeon supports enum generation. For example:
|
||||
```dart
|
||||
enum State {
|
||||
pending,
|
||||
success,
|
||||
error,
|
||||
}
|
||||
|
||||
class StateResult {
|
||||
String? errorMessage;
|
||||
State? state;
|
||||
}
|
||||
|
||||
@HostApi()
|
||||
abstract class Api {
|
||||
StateResult queryState();
|
||||
}
|
||||
```
|
||||
|
||||
Generates on Dart, Java, Objective-C:
|
||||
```dart
|
||||
enum State {
|
||||
pending,
|
||||
success,
|
||||
error,
|
||||
}
|
||||
```
|
||||
|
||||
```java
|
||||
public enum State {
|
||||
pending(0),
|
||||
success(1),
|
||||
error(2);
|
||||
|
||||
private int index;
|
||||
private State(final int index) {
|
||||
this.index = index;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
```objc
|
||||
typedef NS_ENUM(NSUInteger, State) {
|
||||
StatePending = 0,
|
||||
StateSuccess = 1,
|
||||
StateError = 2,
|
||||
};
|
||||
```
|
||||
|
||||
## Feedback
|
||||
|
||||
File an issue in [flutter/flutter](https://github.com/flutter/flutter) with the
|
||||
|
@ -8,7 +8,7 @@ import 'dart:mirrors';
|
||||
import 'ast.dart';
|
||||
|
||||
/// The current version of pigeon. This must match the version in pubspec.yaml.
|
||||
const String pigeonVersion = '0.2.1';
|
||||
const String pigeonVersion = '0.2.2';
|
||||
|
||||
/// Read all the content from [stdin] to a String.
|
||||
String readStdin() {
|
||||
|
@ -2,7 +2,7 @@ name: pigeon
|
||||
description: Code generator tool to make communication between Flutter and the host platform type-safe and easier.
|
||||
repository: https://github.com/flutter/packages/tree/master/packages/pigeon
|
||||
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3Apigeon
|
||||
version: 0.2.1 # This must match the version in lib/generator_tools.dart
|
||||
version: 0.2.2 # This must match the version in lib/generator_tools.dart
|
||||
|
||||
environment:
|
||||
sdk: '>=2.12.0 <3.0.0'
|
||||
|
Reference in New Issue
Block a user