22// Use of this source code is governed by a BSD-style license that can be
33// found in the LICENSE file.
44
5- // TODO(egarciad): Remove once Mockito has been migrated to null safety.
6- // @dart = 2.9
7-
85import 'dart:ui' ;
96import 'package:flutter/material.dart' ;
107import 'package:flutter_test/flutter_test.dart' ;
@@ -20,7 +17,7 @@ void main() {
2017 final MockUrlLauncher mock = MockUrlLauncher ();
2118 UrlLauncherPlatform .instance = mock;
2219
23- PlatformMessageCallback realOnPlatformMessage;
20+ PlatformMessageCallback ? realOnPlatformMessage;
2421 setUp (() {
2522 realOnPlatformMessage = window.onPlatformMessage;
2623 });
@@ -31,11 +28,11 @@ void main() {
3128 group ('$Link ' , () {
3229 testWidgets ('handles null uri correctly' , (WidgetTester tester) async {
3330 bool isBuilt = false ;
34- FollowLink followLink;
31+ FollowLink ? followLink;
3532
3633 final Link link = Link (
3734 uri: null ,
38- builder: (BuildContext context, FollowLink followLink2) {
35+ builder: (BuildContext context, FollowLink ? followLink2) {
3936 isBuilt = true ;
4037 followLink = followLink2;
4138 return Container ();
@@ -50,12 +47,12 @@ void main() {
5047
5148 testWidgets ('calls url_launcher for external URLs with blank target' ,
5249 (WidgetTester tester) async {
53- FollowLink followLink;
50+ FollowLink ? followLink;
5451
5552 await tester.pumpWidget (Link (
5653 uri: Uri .parse ('http://example.com/foobar' ),
5754 target: LinkTarget .blank,
58- builder: (BuildContext context, FollowLink followLink2) {
55+ builder: (BuildContext context, FollowLink ? followLink2) {
5956 followLink = followLink2;
6057 return Container ();
6158 },
@@ -64,7 +61,7 @@ void main() {
6461 when (mock.canLaunch ('http://example.com/foobar' ))
6562 .thenAnswer ((realInvocation) => Future <bool >.value (true ));
6663 clearInteractions (mock);
67- await followLink ();
64+ await followLink ! ();
6865
6966 verifyInOrder ([
7067 mock.canLaunch ('http://example.com/foobar' ),
@@ -82,12 +79,12 @@ void main() {
8279
8380 testWidgets ('calls url_launcher for external URLs with self target' ,
8481 (WidgetTester tester) async {
85- FollowLink followLink;
82+ FollowLink ? followLink;
8683
8784 await tester.pumpWidget (Link (
8885 uri: Uri .parse ('http://example.com/foobar' ),
8986 target: LinkTarget .self,
90- builder: (BuildContext context, FollowLink followLink2) {
87+ builder: (BuildContext context, FollowLink ? followLink2) {
9188 followLink = followLink2;
9289 return Container ();
9390 },
@@ -96,7 +93,7 @@ void main() {
9693 when (mock.canLaunch ('http://example.com/foobar' ))
9794 .thenAnswer ((realInvocation) => Future <bool >.value (true ));
9895 clearInteractions (mock);
99- await followLink ();
96+ await followLink ! ();
10097
10198 verifyInOrder ([
10299 mock.canLaunch ('http://example.com/foobar' ),
@@ -125,21 +122,21 @@ void main() {
125122 final List <MethodCall > frameworkCalls = < MethodCall > [];
126123 window.onPlatformMessage = (
127124 String name,
128- ByteData data,
129- PlatformMessageResponseCallback callback,
125+ ByteData ? data,
126+ PlatformMessageResponseCallback ? callback,
130127 ) {
131128 frameworkCalls.add (_codec.decodeMethodCall (data));
132- realOnPlatformMessage (name, data, callback);
129+ realOnPlatformMessage ! (name, data, callback);
133130 };
134131
135132 final Uri uri = Uri .parse ('/foo/bar' );
136- FollowLink followLink;
133+ FollowLink ? followLink;
137134
138135 await tester.pumpWidget (MaterialApp (
139136 routes: < String , WidgetBuilder > {
140137 '/' : (BuildContext context) => Link (
141138 uri: uri,
142- builder: (BuildContext context, FollowLink followLink2) {
139+ builder: (BuildContext context, FollowLink ? followLink2) {
143140 followLink = followLink2;
144141 return Container ();
145142 },
@@ -151,7 +148,7 @@ void main() {
151148 engineCalls.clear ();
152149 frameworkCalls.clear ();
153150 clearInteractions (mock);
154- await followLink ();
151+ await followLink ! ();
155152
156153 // Shouldn't use url_launcher when uri is an internal route name.
157154 verifyZeroInteractions (mock);
@@ -191,19 +188,19 @@ void main() {
191188 final List <MethodCall > frameworkCalls = < MethodCall > [];
192189 window.onPlatformMessage = (
193190 String name,
194- ByteData data,
195- PlatformMessageResponseCallback callback,
191+ ByteData ? data,
192+ PlatformMessageResponseCallback ? callback,
196193 ) {
197194 frameworkCalls.add (_codec.decodeMethodCall (data));
198- realOnPlatformMessage (name, data, callback);
195+ realOnPlatformMessage ! (name, data, callback);
199196 };
200197
201198 final Uri uri = Uri .parse ('/foo/bar' );
202- FollowLink followLink;
199+ FollowLink ? followLink;
203200
204201 final Link link = Link (
205202 uri: uri,
206- builder: (BuildContext context, FollowLink followLink2) {
203+ builder: (BuildContext context, FollowLink ? followLink2) {
207204 followLink = followLink2;
208205 return Container ();
209206 },
@@ -218,7 +215,7 @@ void main() {
218215 engineCalls.clear ();
219216 frameworkCalls.clear ();
220217 clearInteractions (mock);
221- await followLink ();
218+ await followLink ! ();
222219
223220 // Shouldn't use url_launcher when uri is an internal route name.
224221 verifyZeroInteractions (mock);
@@ -261,8 +258,8 @@ class MockRouteInformationParser extends Mock
261258 }
262259}
263260
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});
266263
267264 final WidgetBuilder builder;
268265
0 commit comments