Visitar URL original
[pigeon] migrate to null-safety by Goddchen · Pull Request #300 · flutter/packages · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
checked up updated mock_handler_tester generated code, not sure why t…
…he test is failing remotely, works locally
  • Loading branch information
gaaclarke committed Mar 19, 2021
commit ecee68d3607946188fa757e2ce4e6c31c2312bd5
33 changes: 13 additions & 20 deletions packages/pigeon/mock_handler_tester/test/message.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Autogenerated from Pigeon (v0.2.0-nullsafety.0), do not edit directly.
// See also: https://pub.dev/packages/pigeon
// ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import
// ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types
// @dart = 2.12

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you make the default output null-safe now? I think that's a good idea.

import 'dart:async';
import 'dart:typed_data' show Uint8List, Int32List, Int64List, Float64List;
Expand All @@ -18,10 +18,7 @@ class SearchReply {
return pigeonMap;
}

static SearchReply decode(Object? message) {
if (message == null) {
return SearchReply();
}
static SearchReply decode(Object message) {
final Map<Object?, Object?> pigeonMap = message as Map<Object?, Object?>;
return SearchReply()
..result = pigeonMap['result'] as String?
Expand All @@ -42,10 +39,7 @@ class SearchRequest {
return pigeonMap;
}

static SearchRequest decode(Object? message) {
if (message == null) {
return SearchRequest();
}
static SearchRequest decode(Object message) {
final Map<Object?, Object?> pigeonMap = message as Map<Object?, Object?>;
return SearchRequest()
..query = pigeonMap['query'] as String?
Expand All @@ -63,10 +57,7 @@ class Nested {
return pigeonMap;
}

static Nested decode(Object? message) {
if (message == null) {
return Nested();
}
static Nested decode(Object message) {
final Map<Object?, Object?> pigeonMap = message as Map<Object?, Object?>;
return Nested()
..request = pigeonMap['request'] != null
Expand All @@ -85,7 +76,9 @@ abstract class FlutterSearchApi {
channel.setMessageHandler(null);
} else {
channel.setMessageHandler((Object? message) async {
final SearchRequest input = SearchRequest.decode(message);
assert(message != null,
'Argument for dev.flutter.pigeon.FlutterSearchApi.search was null. Expected SearchRequest.');
final SearchRequest input = SearchRequest.decode(message!);
final SearchReply output = api.search(input);
return output.encode();
});
Expand All @@ -109,9 +102,9 @@ class NestedApi {
);
} else if (replyMap['error'] != null) {
final Map<Object?, Object?> error =
replyMap['error']! as Map<Object?, Object?>;
(replyMap['error'] as Map<Object?, Object?>?)!;
throw PlatformException(
code: error['code'] as String? ?? 'unknown',
code: (error['code'] as String?)!,
message: error['message'] as String?,
details: error['details'],
);
Expand All @@ -135,9 +128,9 @@ class Api {
);
} else if (replyMap['error'] != null) {
final Map<Object?, Object?> error =
replyMap['error']! as Map<Object?, Object?>;
(replyMap['error'] as Map<Object?, Object?>?)!;
throw PlatformException(
code: error['code'] as String? ?? 'unknown',
code: (error['code'] as String?)!,
message: error['message'] as String?,
details: error['details'],
);
Expand All @@ -160,9 +153,9 @@ class Api {
);
} else if (replyMap['error'] != null) {
final Map<Object?, Object?> error =
replyMap['error']! as Map<Object?, Object?>;
(replyMap['error'] as Map<Object?, Object?>?)!;
throw PlatformException(
code: error['code'] as String? ?? 'unknown',
code: (error['code'] as String?)!,
message: error['message'] as String?,
details: error['details'],
);
Expand Down
8 changes: 6 additions & 2 deletions packages/pigeon/mock_handler_tester/test/test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ abstract class TestNestedApi {
channel.setMockMessageHandler(null);
} else {
channel.setMockMessageHandler((Object? message) async {
final Nested input = Nested.decode(message);
assert(message != null,
'Argument for dev.flutter.pigeon.NestedApi.search was null. Expected Nested.');
final Nested input = Nested.decode(message!);
final SearchReply output = api.search(input);
return <Object?, Object?>{'result': output.encode()};
});
Expand Down Expand Up @@ -52,7 +54,9 @@ abstract class TestHostApi {
channel.setMockMessageHandler(null);
} else {
channel.setMockMessageHandler((Object? message) async {
final SearchRequest input = SearchRequest.decode(message);
assert(message != null,
'Argument for dev.flutter.pigeon.Api.search was null. Expected SearchRequest.');
final SearchRequest input = SearchRequest.decode(message!);
final SearchReply output = api.search(input);
return <Object?, Object?>{'result': output.encode()};
});
Expand Down