22// Use of this source code is governed by a BSD-style license that can be
33// found in the LICENSE file.
44
5- // @dart = 2.8
6-
75import 'dart:convert' show utf8;
86
97import 'package:flutter/services.dart' ;
@@ -13,13 +11,12 @@ void main() {
1311 TestWidgetsFlutterBinding .ensureInitialized ();
1412
1513 group ('TextInput message channels' , () {
16- FakeTextChannel fakeTextChannel;
17- FakeAutofillScope scope;
14+ late FakeTextChannel fakeTextChannel;
15+ final FakeAutofillScope scope = FakeAutofillScope () ;
1816
1917 setUp (() {
2018 fakeTextChannel = FakeTextChannel ((MethodCall call) async {});
2119 TextInput .setChannel (fakeTextChannel);
22- scope ?? = FakeAutofillScope ();
2320 scope.clients.clear ();
2421 });
2522
@@ -28,35 +25,8 @@ void main() {
2825 TextInput .setChannel (SystemChannels .textInput);
2926 });
3027
31- test ('mandatory fields are mandatory' , () async {
32- AutofillConfiguration config;
33- try {
34- config = AutofillConfiguration (
35- uniqueIdentifier: null ,
36- autofillHints: const < String > ['test' ],
37- currentEditingValue: const TextEditingValue (),
38- );
39- } catch (e) {
40- expect (e.toString (), contains ('uniqueIdentifier != null' ));
41- }
42-
43- expect (config, isNull);
44-
45- try {
46- config = AutofillConfiguration (
47- uniqueIdentifier: 'id' ,
48- autofillHints: null ,
49- currentEditingValue: const TextEditingValue (),
50- );
51- } catch (e) {
52- expect (e.toString (), contains ('autofillHints != null' ));
53- }
54-
55- expect (config, isNull);
56- });
57-
5828 test ('throws if the hint list is empty' , () async {
59- Map <String , dynamic > json;
29+ Map <String , dynamic >? json;
6030 try {
6131 const AutofillConfiguration config = AutofillConfiguration (
6232 uniqueIdentifier: 'id' ,
@@ -113,7 +83,7 @@ void main() {
11383 ]);
11484
11585 const TextEditingValue text2 = TextEditingValue (text: 'Text 2' );
116- fakeTextChannel.incoming (MethodCall (
86+ fakeTextChannel.incoming? . call (MethodCall (
11787 'TextInputClient.updateEditingStateWithTag' ,
11888 < dynamic > [0 , < String , dynamic > { client2.autofillId : text2.toJSON () }],
11989 ));
@@ -130,7 +100,7 @@ class FakeAutofillClient implements TextInputClient, AutofillClient {
130100 String get autofillId => hashCode.toString ();
131101
132102 @override
133- TextInputConfiguration textInputConfiguration;
103+ late TextInputConfiguration textInputConfiguration;
134104
135105 @override
136106 void updateEditingValue (TextEditingValue newEditingValue) {
@@ -139,7 +109,7 @@ class FakeAutofillClient implements TextInputClient, AutofillClient {
139109 }
140110
141111 @override
142- AutofillScope currentAutofillScope;
112+ AutofillScope ? currentAutofillScope;
143113
144114 String latestMethodCall = '' ;
145115
@@ -179,7 +149,7 @@ class FakeAutofillScope with AutofillScopeMixin implements AutofillScope {
179149 Iterable <AutofillClient > get autofillClients => clients.values;
180150
181151 @override
182- AutofillClient getAutofillClient (String autofillId) => clients[autofillId];
152+ AutofillClient getAutofillClient (String autofillId) => clients[autofillId]! ;
183153
184154 void register (AutofillClient client) {
185155 clients.putIfAbsent (client.autofillId, () => client);
@@ -190,7 +160,7 @@ class FakeTextChannel implements MethodChannel {
190160 FakeTextChannel (this .outgoing) : assert (outgoing != null );
191161
192162 Future <dynamic > Function (MethodCall ) outgoing;
193- Future <void > Function (MethodCall ) incoming;
163+ Future <void > Function (MethodCall )? incoming;
194164
195165 List <MethodCall > outgoingCalls = < MethodCall > [];
196166
@@ -217,18 +187,18 @@ class FakeTextChannel implements MethodChannel {
217187 String get name => 'flutter/textinput' ;
218188
219189 @override
220- void setMethodCallHandler (Future <void > Function (MethodCall call) handler) {
190+ void setMethodCallHandler (Future <void > Function (MethodCall call)? handler) {
221191 incoming = handler;
222192 }
223193
224194 @override
225- bool checkMethodCallHandler (Future <void > Function (MethodCall call) handler) => throw UnimplementedError ();
195+ bool checkMethodCallHandler (Future <void > Function (MethodCall call)? handler) => throw UnimplementedError ();
226196
227197 @override
228- void setMockMethodCallHandler (Future <void > Function (MethodCall call) handler) => throw UnimplementedError ();
198+ void setMockMethodCallHandler (Future <void > Function (MethodCall call)? handler) => throw UnimplementedError ();
229199
230200 @override
231- bool checkMockMethodCallHandler (Future <void > Function (MethodCall call) handler) => throw UnimplementedError ();
201+ bool checkMockMethodCallHandler (Future <void > Function (MethodCall call)? handler) => throw UnimplementedError ();
232202
233203 void validateOutgoingMethodCalls (List <MethodCall > calls) {
234204 expect (outgoingCalls.length, calls.length);
0 commit comments