[pigeon] updated readme and made version 0.2.2 (#372)

This commit is contained in:
gaaclarke
2021-06-14 11:32:33 -07:00
committed by GitHub
parent 27b2ce612e
commit 6833bcc29c
4 changed files with 61 additions and 4 deletions

View File

@ -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.

View File

@ -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

View File

@ -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() {

View File

@ -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'