mirror of
https://github.com/flutter/packages.git
synced 2025-07-01 23:51:55 +08:00
[pigeon] fixed cast error that can happen with FlutterApi and primitive lists (#506)
This commit is contained in:
@ -1,3 +1,8 @@
|
||||
## 1.0.9
|
||||
|
||||
* [dart] Fixed cast exception that can happen with primitive data types with
|
||||
type arguments in FlutterApi's.
|
||||
|
||||
## 1.0.8
|
||||
|
||||
* [front-end] Started accepting explicit Object references in type arguments.
|
||||
|
@ -236,20 +236,21 @@ void _writeFlutterApi(
|
||||
);
|
||||
indent.writeln('$returnType ${func.name}($argSignature);');
|
||||
}
|
||||
indent.write('static void setup(${api.name}$nullTag api) ');
|
||||
indent.write(
|
||||
'static void setup(${api.name}$nullTag api, {BinaryMessenger$nullTag binaryMessenger}) ');
|
||||
indent.scoped('{', '}', () {
|
||||
for (final Method func in api.methods) {
|
||||
indent.write('');
|
||||
indent.scoped('{', '}', () {
|
||||
indent.writeln(
|
||||
'const BasicMessageChannel<Object$nullTag> channel = BasicMessageChannel<Object$nullTag>(',
|
||||
'final BasicMessageChannel<Object$nullTag> channel = BasicMessageChannel<Object$nullTag>(',
|
||||
);
|
||||
final String channelName = channelNameFunc == null
|
||||
? makeChannelName(api, func)
|
||||
: channelNameFunc(func);
|
||||
indent.nest(2, () {
|
||||
indent.writeln(
|
||||
'\'$channelName\', codec);',
|
||||
'\'$channelName\', codec, binaryMessenger: binaryMessenger);',
|
||||
);
|
||||
});
|
||||
final String messageHandlerSetter =
|
||||
@ -288,8 +289,13 @@ void _writeFlutterApi(
|
||||
enumerate(func.arguments, (int count, NamedType arg) {
|
||||
final String argType = _addGenericTypes(arg.type, nullTag);
|
||||
final String argName = argNameFunc(count, arg);
|
||||
final String genericArgType =
|
||||
_makeGenericTypeArguments(arg.type, nullTag);
|
||||
final String castCall =
|
||||
_makeGenericCastCall(arg.type, nullTag);
|
||||
|
||||
indent.writeln(
|
||||
'final $argType$nullTag $argName = $argsArray[$count] as $argType$nullTag;');
|
||||
'final $argType$nullTag $argName = ($argsArray[$count] as $genericArgType$nullTag)${castCall.isEmpty ? '' : '$nullTag$castCall'};');
|
||||
indent.writeln(
|
||||
'assert($argName != null, \'Argument for $channelName was null, expected non-null $argType.\');');
|
||||
});
|
||||
|
@ -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 = '1.0.8';
|
||||
const String pigeonVersion = '1.0.9';
|
||||
|
||||
/// Read all the content from [stdin] to a String.
|
||||
String readStdin() {
|
||||
|
@ -183,10 +183,12 @@ abstract class FlutterEverything {
|
||||
|
||||
Everything giveMeEverything();
|
||||
Everything echo(Everything everything);
|
||||
static void setup(FlutterEverything? api) {
|
||||
static void setup(FlutterEverything? api,
|
||||
{BinaryMessenger? binaryMessenger}) {
|
||||
{
|
||||
const BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
|
||||
'dev.flutter.pigeon.FlutterEverything.giveMeEverything', codec);
|
||||
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
|
||||
'dev.flutter.pigeon.FlutterEverything.giveMeEverything', codec,
|
||||
binaryMessenger: binaryMessenger);
|
||||
if (api == null) {
|
||||
channel.setMessageHandler(null);
|
||||
} else {
|
||||
@ -198,8 +200,9 @@ abstract class FlutterEverything {
|
||||
}
|
||||
}
|
||||
{
|
||||
const BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
|
||||
'dev.flutter.pigeon.FlutterEverything.echo', codec);
|
||||
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
|
||||
'dev.flutter.pigeon.FlutterEverything.echo', codec,
|
||||
binaryMessenger: binaryMessenger);
|
||||
if (api == null) {
|
||||
channel.setMessageHandler(null);
|
||||
} else {
|
||||
@ -207,7 +210,7 @@ abstract class FlutterEverything {
|
||||
assert(message != null,
|
||||
'Argument for dev.flutter.pigeon.FlutterEverything.echo was null.');
|
||||
final List<Object?> args = (message as List<Object?>?)!;
|
||||
final Everything? arg_everything = args[0] as Everything?;
|
||||
final Everything? arg_everything = (args[0] as Everything?);
|
||||
assert(arg_everything != null,
|
||||
'Argument for dev.flutter.pigeon.FlutterEverything.echo was null, expected non-null Everything.');
|
||||
final Everything output = api.echo(arg_everything!);
|
||||
|
@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
// Autogenerated from Pigeon (v0.3.0), do not edit directly.
|
||||
// Autogenerated from Pigeon (v1.0.8), 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, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, unused_shown_name
|
||||
// @dart = 2.12
|
||||
@ -61,10 +61,12 @@ abstract class MultipleArityFlutterApi {
|
||||
static const MessageCodec<Object?> codec = _MultipleArityFlutterApiCodec();
|
||||
|
||||
int subtract(int x, int y);
|
||||
static void setup(MultipleArityFlutterApi? api) {
|
||||
static void setup(MultipleArityFlutterApi? api,
|
||||
{BinaryMessenger? binaryMessenger}) {
|
||||
{
|
||||
const BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
|
||||
'dev.flutter.pigeon.MultipleArityFlutterApi.subtract', codec);
|
||||
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
|
||||
'dev.flutter.pigeon.MultipleArityFlutterApi.subtract', codec,
|
||||
binaryMessenger: binaryMessenger);
|
||||
if (api == null) {
|
||||
channel.setMessageHandler(null);
|
||||
} else {
|
||||
@ -72,10 +74,10 @@ abstract class MultipleArityFlutterApi {
|
||||
assert(message != null,
|
||||
'Argument for dev.flutter.pigeon.MultipleArityFlutterApi.subtract was null.');
|
||||
final List<Object?> args = (message as List<Object?>?)!;
|
||||
final int? arg_x = args[0] as int?;
|
||||
final int? arg_x = (args[0] as int?);
|
||||
assert(arg_x != null,
|
||||
'Argument for dev.flutter.pigeon.MultipleArityFlutterApi.subtract was null, expected non-null int.');
|
||||
final int? arg_y = args[1] as int?;
|
||||
final int? arg_y = (args[1] as int?);
|
||||
assert(arg_y != null,
|
||||
'Argument for dev.flutter.pigeon.MultipleArityFlutterApi.subtract was null, expected non-null int.');
|
||||
final int output = api.subtract(arg_x!, arg_y!);
|
||||
|
@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
// Autogenerated from Pigeon (v0.3.0), do not edit directly.
|
||||
// Autogenerated from Pigeon (v1.0.8), 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, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, unused_shown_name
|
||||
// @dart = 2.12
|
||||
|
@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
// Autogenerated from Pigeon (v0.3.0), do not edit directly.
|
||||
// Autogenerated from Pigeon (v1.0.8), 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, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, unused_shown_name
|
||||
// @dart = 2.12
|
||||
@ -270,10 +270,12 @@ abstract class PrimitiveFlutterApi {
|
||||
Int32List anInt32List(Int32List value);
|
||||
List<bool?> aBoolList(List<bool?> value);
|
||||
Map<String?, int?> aStringIntMap(Map<String?, int?> value);
|
||||
static void setup(PrimitiveFlutterApi? api) {
|
||||
static void setup(PrimitiveFlutterApi? api,
|
||||
{BinaryMessenger? binaryMessenger}) {
|
||||
{
|
||||
const BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
|
||||
'dev.flutter.pigeon.PrimitiveFlutterApi.anInt', codec);
|
||||
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
|
||||
'dev.flutter.pigeon.PrimitiveFlutterApi.anInt', codec,
|
||||
binaryMessenger: binaryMessenger);
|
||||
if (api == null) {
|
||||
channel.setMessageHandler(null);
|
||||
} else {
|
||||
@ -281,7 +283,7 @@ abstract class PrimitiveFlutterApi {
|
||||
assert(message != null,
|
||||
'Argument for dev.flutter.pigeon.PrimitiveFlutterApi.anInt was null.');
|
||||
final List<Object?> args = (message as List<Object?>?)!;
|
||||
final int? arg_value = args[0] as int?;
|
||||
final int? arg_value = (args[0] as int?);
|
||||
assert(arg_value != null,
|
||||
'Argument for dev.flutter.pigeon.PrimitiveFlutterApi.anInt was null, expected non-null int.');
|
||||
final int output = api.anInt(arg_value!);
|
||||
@ -290,8 +292,9 @@ abstract class PrimitiveFlutterApi {
|
||||
}
|
||||
}
|
||||
{
|
||||
const BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
|
||||
'dev.flutter.pigeon.PrimitiveFlutterApi.aBool', codec);
|
||||
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
|
||||
'dev.flutter.pigeon.PrimitiveFlutterApi.aBool', codec,
|
||||
binaryMessenger: binaryMessenger);
|
||||
if (api == null) {
|
||||
channel.setMessageHandler(null);
|
||||
} else {
|
||||
@ -299,7 +302,7 @@ abstract class PrimitiveFlutterApi {
|
||||
assert(message != null,
|
||||
'Argument for dev.flutter.pigeon.PrimitiveFlutterApi.aBool was null.');
|
||||
final List<Object?> args = (message as List<Object?>?)!;
|
||||
final bool? arg_value = args[0] as bool?;
|
||||
final bool? arg_value = (args[0] as bool?);
|
||||
assert(arg_value != null,
|
||||
'Argument for dev.flutter.pigeon.PrimitiveFlutterApi.aBool was null, expected non-null bool.');
|
||||
final bool output = api.aBool(arg_value!);
|
||||
@ -308,8 +311,9 @@ abstract class PrimitiveFlutterApi {
|
||||
}
|
||||
}
|
||||
{
|
||||
const BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
|
||||
'dev.flutter.pigeon.PrimitiveFlutterApi.aString', codec);
|
||||
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
|
||||
'dev.flutter.pigeon.PrimitiveFlutterApi.aString', codec,
|
||||
binaryMessenger: binaryMessenger);
|
||||
if (api == null) {
|
||||
channel.setMessageHandler(null);
|
||||
} else {
|
||||
@ -317,7 +321,7 @@ abstract class PrimitiveFlutterApi {
|
||||
assert(message != null,
|
||||
'Argument for dev.flutter.pigeon.PrimitiveFlutterApi.aString was null.');
|
||||
final List<Object?> args = (message as List<Object?>?)!;
|
||||
final String? arg_value = args[0] as String?;
|
||||
final String? arg_value = (args[0] as String?);
|
||||
assert(arg_value != null,
|
||||
'Argument for dev.flutter.pigeon.PrimitiveFlutterApi.aString was null, expected non-null String.');
|
||||
final String output = api.aString(arg_value!);
|
||||
@ -326,8 +330,9 @@ abstract class PrimitiveFlutterApi {
|
||||
}
|
||||
}
|
||||
{
|
||||
const BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
|
||||
'dev.flutter.pigeon.PrimitiveFlutterApi.aDouble', codec);
|
||||
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
|
||||
'dev.flutter.pigeon.PrimitiveFlutterApi.aDouble', codec,
|
||||
binaryMessenger: binaryMessenger);
|
||||
if (api == null) {
|
||||
channel.setMessageHandler(null);
|
||||
} else {
|
||||
@ -335,7 +340,7 @@ abstract class PrimitiveFlutterApi {
|
||||
assert(message != null,
|
||||
'Argument for dev.flutter.pigeon.PrimitiveFlutterApi.aDouble was null.');
|
||||
final List<Object?> args = (message as List<Object?>?)!;
|
||||
final double? arg_value = args[0] as double?;
|
||||
final double? arg_value = (args[0] as double?);
|
||||
assert(arg_value != null,
|
||||
'Argument for dev.flutter.pigeon.PrimitiveFlutterApi.aDouble was null, expected non-null double.');
|
||||
final double output = api.aDouble(arg_value!);
|
||||
@ -344,8 +349,9 @@ abstract class PrimitiveFlutterApi {
|
||||
}
|
||||
}
|
||||
{
|
||||
const BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
|
||||
'dev.flutter.pigeon.PrimitiveFlutterApi.aMap', codec);
|
||||
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
|
||||
'dev.flutter.pigeon.PrimitiveFlutterApi.aMap', codec,
|
||||
binaryMessenger: binaryMessenger);
|
||||
if (api == null) {
|
||||
channel.setMessageHandler(null);
|
||||
} else {
|
||||
@ -354,7 +360,7 @@ abstract class PrimitiveFlutterApi {
|
||||
'Argument for dev.flutter.pigeon.PrimitiveFlutterApi.aMap was null.');
|
||||
final List<Object?> args = (message as List<Object?>?)!;
|
||||
final Map<Object?, Object?>? arg_value =
|
||||
args[0] as Map<Object?, Object?>?;
|
||||
(args[0] as Map<Object?, Object?>?);
|
||||
assert(arg_value != null,
|
||||
'Argument for dev.flutter.pigeon.PrimitiveFlutterApi.aMap was null, expected non-null Map<Object?, Object?>.');
|
||||
final Map<Object?, Object?> output = api.aMap(arg_value!);
|
||||
@ -363,8 +369,9 @@ abstract class PrimitiveFlutterApi {
|
||||
}
|
||||
}
|
||||
{
|
||||
const BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
|
||||
'dev.flutter.pigeon.PrimitiveFlutterApi.aList', codec);
|
||||
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
|
||||
'dev.flutter.pigeon.PrimitiveFlutterApi.aList', codec,
|
||||
binaryMessenger: binaryMessenger);
|
||||
if (api == null) {
|
||||
channel.setMessageHandler(null);
|
||||
} else {
|
||||
@ -372,7 +379,7 @@ abstract class PrimitiveFlutterApi {
|
||||
assert(message != null,
|
||||
'Argument for dev.flutter.pigeon.PrimitiveFlutterApi.aList was null.');
|
||||
final List<Object?> args = (message as List<Object?>?)!;
|
||||
final List<Object?>? arg_value = args[0] as List<Object?>?;
|
||||
final List<Object?>? arg_value = (args[0] as List<Object?>?);
|
||||
assert(arg_value != null,
|
||||
'Argument for dev.flutter.pigeon.PrimitiveFlutterApi.aList was null, expected non-null List<Object?>.');
|
||||
final List<Object?> output = api.aList(arg_value!);
|
||||
@ -381,8 +388,9 @@ abstract class PrimitiveFlutterApi {
|
||||
}
|
||||
}
|
||||
{
|
||||
const BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
|
||||
'dev.flutter.pigeon.PrimitiveFlutterApi.anInt32List', codec);
|
||||
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
|
||||
'dev.flutter.pigeon.PrimitiveFlutterApi.anInt32List', codec,
|
||||
binaryMessenger: binaryMessenger);
|
||||
if (api == null) {
|
||||
channel.setMessageHandler(null);
|
||||
} else {
|
||||
@ -390,7 +398,7 @@ abstract class PrimitiveFlutterApi {
|
||||
assert(message != null,
|
||||
'Argument for dev.flutter.pigeon.PrimitiveFlutterApi.anInt32List was null.');
|
||||
final List<Object?> args = (message as List<Object?>?)!;
|
||||
final Int32List? arg_value = args[0] as Int32List?;
|
||||
final Int32List? arg_value = (args[0] as Int32List?);
|
||||
assert(arg_value != null,
|
||||
'Argument for dev.flutter.pigeon.PrimitiveFlutterApi.anInt32List was null, expected non-null Int32List.');
|
||||
final Int32List output = api.anInt32List(arg_value!);
|
||||
@ -399,8 +407,9 @@ abstract class PrimitiveFlutterApi {
|
||||
}
|
||||
}
|
||||
{
|
||||
const BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
|
||||
'dev.flutter.pigeon.PrimitiveFlutterApi.aBoolList', codec);
|
||||
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
|
||||
'dev.flutter.pigeon.PrimitiveFlutterApi.aBoolList', codec,
|
||||
binaryMessenger: binaryMessenger);
|
||||
if (api == null) {
|
||||
channel.setMessageHandler(null);
|
||||
} else {
|
||||
@ -408,7 +417,8 @@ abstract class PrimitiveFlutterApi {
|
||||
assert(message != null,
|
||||
'Argument for dev.flutter.pigeon.PrimitiveFlutterApi.aBoolList was null.');
|
||||
final List<Object?> args = (message as List<Object?>?)!;
|
||||
final List<bool?>? arg_value = args[0] as List<bool?>?;
|
||||
final List<bool?>? arg_value =
|
||||
(args[0] as List<Object?>?)?.cast<bool?>();
|
||||
assert(arg_value != null,
|
||||
'Argument for dev.flutter.pigeon.PrimitiveFlutterApi.aBoolList was null, expected non-null List<bool?>.');
|
||||
final List<bool?> output = api.aBoolList(arg_value!);
|
||||
@ -417,8 +427,9 @@ abstract class PrimitiveFlutterApi {
|
||||
}
|
||||
}
|
||||
{
|
||||
const BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
|
||||
'dev.flutter.pigeon.PrimitiveFlutterApi.aStringIntMap', codec);
|
||||
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
|
||||
'dev.flutter.pigeon.PrimitiveFlutterApi.aStringIntMap', codec,
|
||||
binaryMessenger: binaryMessenger);
|
||||
if (api == null) {
|
||||
channel.setMessageHandler(null);
|
||||
} else {
|
||||
@ -426,7 +437,8 @@ abstract class PrimitiveFlutterApi {
|
||||
assert(message != null,
|
||||
'Argument for dev.flutter.pigeon.PrimitiveFlutterApi.aStringIntMap was null.');
|
||||
final List<Object?> args = (message as List<Object?>?)!;
|
||||
final Map<String?, int?>? arg_value = args[0] as Map<String?, int?>?;
|
||||
final Map<String?, int?>? arg_value =
|
||||
(args[0] as Map<Object?, Object?>?)?.cast<String?, int?>();
|
||||
assert(arg_value != null,
|
||||
'Argument for dev.flutter.pigeon.PrimitiveFlutterApi.aStringIntMap was null, expected non-null Map<String?, int?>.');
|
||||
final Map<String?, int?> output = api.aStringIntMap(arg_value!);
|
||||
|
@ -6,10 +6,12 @@ import 'package:flutter/services.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:flutter_unit_tests/primitive.dart';
|
||||
import 'package:mockito/annotations.dart';
|
||||
import 'package:mockito/mockito.dart';
|
||||
|
||||
import 'primitive_test.mocks.dart';
|
||||
import 'test_util.dart';
|
||||
|
||||
@GenerateMocks(<Type>[BinaryMessenger])
|
||||
@GenerateMocks(<Type>[BinaryMessenger, PrimitiveFlutterApi])
|
||||
void main() {
|
||||
test('test anInt', () async {
|
||||
final BinaryMessenger mockMessenger = MockBinaryMessenger();
|
||||
@ -37,6 +39,23 @@ void main() {
|
||||
expect(result[0], true);
|
||||
});
|
||||
|
||||
test('test List<bool> flutterapi', () async {
|
||||
final BinaryMessenger mockMessenger = MockBinaryMessenger();
|
||||
final PrimitiveFlutterApi api = MockPrimitiveFlutterApi();
|
||||
when(api.aBoolList(<bool?>[true, false])).thenReturn(<bool?>[]);
|
||||
when(mockMessenger.setMessageHandler(
|
||||
'dev.flutter.pigeon.PrimitiveFlutterApi.aBoolList', any))
|
||||
.thenAnswer((Invocation realInvocation) {
|
||||
final MessageHandler? handler =
|
||||
realInvocation.positionalArguments[1] as MessageHandler?;
|
||||
handler!(PrimitiveFlutterApi.codec.encodeMessage(<Object?>[
|
||||
<Object?>[true, false]
|
||||
]));
|
||||
});
|
||||
PrimitiveFlutterApi.setup(api, binaryMessenger: mockMessenger);
|
||||
verify(api.aBoolList(<bool?>[true, false]));
|
||||
});
|
||||
|
||||
test('test Map<String?, int?>', () async {
|
||||
final BinaryMessenger mockMessenger = MockBinaryMessenger();
|
||||
echoOneArgument(
|
||||
|
@ -1,44 +1,95 @@
|
||||
// Mocks generated by Mockito 5.0.7 from annotations
|
||||
// in flutter_unit_tests/test/null_safe_test.dart.
|
||||
// in flutter_unit_tests/test/primitive_test.dart.
|
||||
// Do not manually edit this file.
|
||||
|
||||
import 'dart:async' as _i3;
|
||||
import 'dart:typed_data' as _i4;
|
||||
import 'dart:async' as _i4;
|
||||
import 'dart:typed_data' as _i2;
|
||||
import 'dart:ui' as _i5;
|
||||
|
||||
import 'package:flutter/src/services/binary_messenger.dart' as _i2;
|
||||
import 'package:flutter/src/services/binary_messenger.dart' as _i3;
|
||||
import 'package:flutter_unit_tests/primitive.dart' as _i6;
|
||||
import 'package:mockito/mockito.dart' as _i1;
|
||||
|
||||
// ignore_for_file: comment_references
|
||||
// ignore_for_file: unnecessary_parenthesis
|
||||
|
||||
// ignore_for_file: prefer_const_constructors
|
||||
|
||||
// ignore_for_file: avoid_redundant_argument_values
|
||||
// ignore_for_file: always_specify_types
|
||||
// Added manually; several methods have moved to
|
||||
// flutter_test/lib/src/deprecated.dart on master, but that hasn't reached
|
||||
// stable yet.
|
||||
// ignore_for_file: override_on_non_overriding_member
|
||||
// ignore_for_file: implicit_dynamic_type
|
||||
// ignore_for_file: subtype_of_disallowed_type
|
||||
|
||||
class _FakeInt32List extends _i1.Fake implements _i2.Int32List {}
|
||||
|
||||
/// A class which mocks [BinaryMessenger].
|
||||
///
|
||||
/// See the documentation for Mockito's code generation for more information.
|
||||
class MockBinaryMessenger extends _i1.Mock implements _i2.BinaryMessenger {
|
||||
class MockBinaryMessenger extends _i1.Mock implements _i3.BinaryMessenger {
|
||||
MockBinaryMessenger() {
|
||||
_i1.throwOnMissingStub(this);
|
||||
}
|
||||
|
||||
@override
|
||||
_i3.Future<void> handlePlatformMessage(String? channel, _i4.ByteData? data,
|
||||
_i4.Future<void> handlePlatformMessage(String? channel, _i2.ByteData? data,
|
||||
_i5.PlatformMessageResponseCallback? callback) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#handlePlatformMessage, [channel, data, callback]),
|
||||
returnValue: Future<void>.value(null),
|
||||
returnValueForMissingStub:
|
||||
Future<dynamic>.value()) as _i3.Future<void>);
|
||||
returnValueForMissingStub: Future.value()) as _i4.Future<void>);
|
||||
@override
|
||||
_i3.Future<_i4.ByteData?>? send(String? channel, _i4.ByteData? message) =>
|
||||
_i4.Future<_i2.ByteData?>? send(String? channel, _i2.ByteData? message) =>
|
||||
(super.noSuchMethod(Invocation.method(#send, [channel, message]))
|
||||
as _i3.Future<_i4.ByteData?>?);
|
||||
as _i4.Future<_i2.ByteData?>?);
|
||||
@override
|
||||
void setMessageHandler(String? channel, _i2.MessageHandler? handler) => super
|
||||
void setMessageHandler(String? channel, _i3.MessageHandler? handler) => super
|
||||
.noSuchMethod(Invocation.method(#setMessageHandler, [channel, handler]),
|
||||
returnValueForMissingStub: null);
|
||||
}
|
||||
|
||||
/// A class which mocks [PrimitiveFlutterApi].
|
||||
///
|
||||
/// See the documentation for Mockito's code generation for more information.
|
||||
class MockPrimitiveFlutterApi extends _i1.Mock
|
||||
implements _i6.PrimitiveFlutterApi {
|
||||
MockPrimitiveFlutterApi() {
|
||||
_i1.throwOnMissingStub(this);
|
||||
}
|
||||
|
||||
@override
|
||||
int anInt(int? value) =>
|
||||
(super.noSuchMethod(Invocation.method(#anInt, [value]), returnValue: 0)
|
||||
as int);
|
||||
@override
|
||||
bool aBool(bool? value) => (super
|
||||
.noSuchMethod(Invocation.method(#aBool, [value]), returnValue: false)
|
||||
as bool);
|
||||
@override
|
||||
String aString(String? value) =>
|
||||
(super.noSuchMethod(Invocation.method(#aString, [value]), returnValue: '')
|
||||
as String);
|
||||
@override
|
||||
double aDouble(double? value) => (super
|
||||
.noSuchMethod(Invocation.method(#aDouble, [value]), returnValue: 0.0)
|
||||
as double);
|
||||
@override
|
||||
Map<Object?, Object?> aMap(Map<Object?, Object?>? value) =>
|
||||
(super.noSuchMethod(Invocation.method(#aMap, [value]),
|
||||
returnValue: <Object?, Object?>{}) as Map<Object?, Object?>);
|
||||
@override
|
||||
List<Object?> aList(List<Object?>? value) =>
|
||||
(super.noSuchMethod(Invocation.method(#aList, [value]),
|
||||
returnValue: <Object?>[]) as List<Object?>);
|
||||
@override
|
||||
_i2.Int32List anInt32List(_i2.Int32List? value) =>
|
||||
(super.noSuchMethod(Invocation.method(#anInt32List, [value]),
|
||||
returnValue: _FakeInt32List()) as _i2.Int32List);
|
||||
@override
|
||||
List<bool?> aBoolList(List<bool?>? value) =>
|
||||
(super.noSuchMethod(Invocation.method(#aBoolList, [value]),
|
||||
returnValue: <bool?>[]) as List<bool?>);
|
||||
@override
|
||||
Map<String?, int?> aStringIntMap(Map<String?, int?>? value) =>
|
||||
(super.noSuchMethod(Invocation.method(#aStringIntMap, [value]),
|
||||
returnValue: <String?, int?>{}) as Map<String?, int?>);
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
archiveVersion = 1;
|
||||
classes = {
|
||||
};
|
||||
objectVersion = 46;
|
||||
objectVersion = 50;
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
@ -281,7 +281,7 @@
|
||||
97C146E61CF9000F007C117D /* Project object */ = {
|
||||
isa = PBXProject;
|
||||
attributes = {
|
||||
LastUpgradeCheck = 1020;
|
||||
LastUpgradeCheck = 1300;
|
||||
ORGANIZATIONNAME = "The Flutter Authors";
|
||||
TargetAttributes = {
|
||||
0D50127123FF75B100CD5B95 = {
|
||||
|
@ -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: 1.0.8 # This must match the version in lib/generator_tools.dart
|
||||
version: 1.0.9 # This must match the version in lib/generator_tools.dart
|
||||
|
||||
environment:
|
||||
sdk: '>=2.12.0 <3.0.0'
|
||||
|
@ -155,8 +155,8 @@ void main() {
|
||||
expect(code, contains('int add(int x, int y)'));
|
||||
expect(code,
|
||||
contains('final List<Object?> args = (message as List<Object?>?)!'));
|
||||
expect(code, contains('final int? arg_x = args[0] as int?'));
|
||||
expect(code, contains('final int? arg_y = args[1] as int?'));
|
||||
expect(code, contains('final int? arg_x = (args[0] as int?)'));
|
||||
expect(code, contains('final int? arg_y = (args[1] as int?)'));
|
||||
expect(code, contains('final int output = api.add(arg_x!, arg_y!)'));
|
||||
});
|
||||
|
||||
@ -940,7 +940,9 @@ void main() {
|
||||
final String code = sink.toString();
|
||||
expect(code, contains('List<int?> doit('));
|
||||
expect(
|
||||
code, contains('final List<int?>? arg_foo = args[0] as List<int?>?'));
|
||||
code,
|
||||
contains(
|
||||
'final List<int?>? arg_foo = (args[0] as List<Object?>?)?.cast<int?>()'));
|
||||
expect(code, contains('final List<int?> output = api.doit(arg_foo!)'));
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user