2
2
// Use of this source code is governed by a BSD-style license that can be
3
3
// found in the LICENSE file.
4
4
5
- // TODO(egarciad): Remove once Mockito has been migrated to null safety.
6
- // @dart = 2.9
7
-
8
5
import 'dart:ui' ;
9
6
import 'package:flutter/material.dart' ;
10
7
import 'package:flutter_test/flutter_test.dart' ;
@@ -20,7 +17,7 @@ void main() {
20
17
final MockUrlLauncher mock = MockUrlLauncher ();
21
18
UrlLauncherPlatform .instance = mock;
22
19
23
- PlatformMessageCallback realOnPlatformMessage;
20
+ PlatformMessageCallback ? realOnPlatformMessage;
24
21
setUp (() {
25
22
realOnPlatformMessage = window.onPlatformMessage;
26
23
});
@@ -31,11 +28,11 @@ void main() {
31
28
group ('$Link ' , () {
32
29
testWidgets ('handles null uri correctly' , (WidgetTester tester) async {
33
30
bool isBuilt = false ;
34
- FollowLink followLink;
31
+ FollowLink ? followLink;
35
32
36
33
final Link link = Link (
37
34
uri: null ,
38
- builder: (BuildContext context, FollowLink followLink2) {
35
+ builder: (BuildContext context, FollowLink ? followLink2) {
39
36
isBuilt = true ;
40
37
followLink = followLink2;
41
38
return Container ();
@@ -50,12 +47,12 @@ void main() {
50
47
51
48
testWidgets ('calls url_launcher for external URLs with blank target' ,
52
49
(WidgetTester tester) async {
53
- FollowLink followLink;
50
+ FollowLink ? followLink;
54
51
55
52
await tester.pumpWidget (Link (
56
53
uri: Uri .parse ('http://example.com/foobar' ),
57
54
target: LinkTarget .blank,
58
- builder: (BuildContext context, FollowLink followLink2) {
55
+ builder: (BuildContext context, FollowLink ? followLink2) {
59
56
followLink = followLink2;
60
57
return Container ();
61
58
},
@@ -64,7 +61,7 @@ void main() {
64
61
when (mock.canLaunch ('http://example.com/foobar' ))
65
62
.thenAnswer ((realInvocation) => Future <bool >.value (true ));
66
63
clearInteractions (mock);
67
- await followLink ();
64
+ await followLink ! ();
68
65
69
66
verifyInOrder ([
70
67
mock.canLaunch ('http://example.com/foobar' ),
@@ -82,12 +79,12 @@ void main() {
82
79
83
80
testWidgets ('calls url_launcher for external URLs with self target' ,
84
81
(WidgetTester tester) async {
85
- FollowLink followLink;
82
+ FollowLink ? followLink;
86
83
87
84
await tester.pumpWidget (Link (
88
85
uri: Uri .parse ('http://example.com/foobar' ),
89
86
target: LinkTarget .self,
90
- builder: (BuildContext context, FollowLink followLink2) {
87
+ builder: (BuildContext context, FollowLink ? followLink2) {
91
88
followLink = followLink2;
92
89
return Container ();
93
90
},
@@ -96,7 +93,7 @@ void main() {
96
93
when (mock.canLaunch ('http://example.com/foobar' ))
97
94
.thenAnswer ((realInvocation) => Future <bool >.value (true ));
98
95
clearInteractions (mock);
99
- await followLink ();
96
+ await followLink ! ();
100
97
101
98
verifyInOrder ([
102
99
mock.canLaunch ('http://example.com/foobar' ),
@@ -125,21 +122,21 @@ void main() {
125
122
final List <MethodCall > frameworkCalls = < MethodCall > [];
126
123
window.onPlatformMessage = (
127
124
String name,
128
- ByteData data,
129
- PlatformMessageResponseCallback callback,
125
+ ByteData ? data,
126
+ PlatformMessageResponseCallback ? callback,
130
127
) {
131
128
frameworkCalls.add (_codec.decodeMethodCall (data));
132
- realOnPlatformMessage (name, data, callback);
129
+ realOnPlatformMessage ! (name, data, callback);
133
130
};
134
131
135
132
final Uri uri = Uri .parse ('/foo/bar' );
136
- FollowLink followLink;
133
+ FollowLink ? followLink;
137
134
138
135
await tester.pumpWidget (MaterialApp (
139
136
routes: < String , WidgetBuilder > {
140
137
'/' : (BuildContext context) => Link (
141
138
uri: uri,
142
- builder: (BuildContext context, FollowLink followLink2) {
139
+ builder: (BuildContext context, FollowLink ? followLink2) {
143
140
followLink = followLink2;
144
141
return Container ();
145
142
},
@@ -151,7 +148,7 @@ void main() {
151
148
engineCalls.clear ();
152
149
frameworkCalls.clear ();
153
150
clearInteractions (mock);
154
- await followLink ();
151
+ await followLink ! ();
155
152
156
153
// Shouldn't use url_launcher when uri is an internal route name.
157
154
verifyZeroInteractions (mock);
@@ -191,19 +188,19 @@ void main() {
191
188
final List <MethodCall > frameworkCalls = < MethodCall > [];
192
189
window.onPlatformMessage = (
193
190
String name,
194
- ByteData data,
195
- PlatformMessageResponseCallback callback,
191
+ ByteData ? data,
192
+ PlatformMessageResponseCallback ? callback,
196
193
) {
197
194
frameworkCalls.add (_codec.decodeMethodCall (data));
198
- realOnPlatformMessage (name, data, callback);
195
+ realOnPlatformMessage ! (name, data, callback);
199
196
};
200
197
201
198
final Uri uri = Uri .parse ('/foo/bar' );
202
- FollowLink followLink;
199
+ FollowLink ? followLink;
203
200
204
201
final Link link = Link (
205
202
uri: uri,
206
- builder: (BuildContext context, FollowLink followLink2) {
203
+ builder: (BuildContext context, FollowLink ? followLink2) {
207
204
followLink = followLink2;
208
205
return Container ();
209
206
},
@@ -218,7 +215,7 @@ void main() {
218
215
engineCalls.clear ();
219
216
frameworkCalls.clear ();
220
217
clearInteractions (mock);
221
- await followLink ();
218
+ await followLink ! ();
222
219
223
220
// Shouldn't use url_launcher when uri is an internal route name.
224
221
verifyZeroInteractions (mock);
@@ -261,8 +258,8 @@ class MockRouteInformationParser extends Mock
261
258
}
262
259
}
263
260
264
- class MockRouterDelegate extends Mock implements RouterDelegate {
265
- MockRouterDelegate ({@ required this .builder});
261
+ class MockRouterDelegate extends Mock implements RouterDelegate < Object > {
262
+ MockRouterDelegate ({required this .builder});
266
263
267
264
final WidgetBuilder builder;
268
265
0 commit comments