-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[url_launcher] Url launcher platform interface null safety #3142
Changes from 4 commits
4597be4
b351ed1
18a8d57
6e84ec9
4555b55
bce0612
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,7 @@ | ||
| ## 2.0.0-nullsafety | ||
|
|
||
| * Migrate to null safety. | ||
|
|
||
| ## 1.0.8 | ||
|
|
||
| * Added webOnlyWindowName parameter | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,8 @@ | |
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
||
| // TODO(mvanbeusekom): Remove once Mockito is migrated to null safety. | ||
| // @dart = 2.9 | ||
| import 'package:mockito/mockito.dart'; | ||
| import 'package:flutter/services.dart'; | ||
| import 'package:flutter_test/flutter_test.dart'; | ||
|
|
@@ -41,6 +43,10 @@ void main() { | |
| final List<MethodCall> log = <MethodCall>[]; | ||
| channel.setMockMethodCallHandler((MethodCall methodCall) async { | ||
| log.add(methodCall); | ||
|
|
||
| // Return null explicitly instead of relying on the implicit null | ||
| // returned by the method channel if no return statement is specified. | ||
| return null; | ||
| }); | ||
|
Comment on lines
+46
to
50
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: what about moving this code to the specific test where it's being used, or the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The problem is that setting the mock method channel (using For now I removed the above logic, as it turns out the method channel will automatically return |
||
|
|
||
| final MethodChannelUrlLauncher launcher = MethodChannelUrlLauncher(); | ||
|
|
@@ -61,6 +67,12 @@ void main() { | |
| ); | ||
| }); | ||
|
|
||
| test('canLaunch should return false if platform returns null', () async { | ||
| final canLaunch = await launcher.canLaunch('http://example.com/'); | ||
|
|
||
| expect(canLaunch, false); | ||
| }); | ||
|
|
||
| test('launch', () async { | ||
| await launcher.launch( | ||
| 'http://example.com/', | ||
|
|
@@ -269,6 +281,20 @@ void main() { | |
| ); | ||
| }); | ||
|
|
||
| test('launch should return false if platform returns null', () async { | ||
| final launched = await launcher.launch( | ||
| 'http://example.com/', | ||
| useSafariVC: true, | ||
| useWebView: false, | ||
| enableJavaScript: false, | ||
| enableDomStorage: false, | ||
| universalLinksOnly: false, | ||
| headers: const <String, String>{}, | ||
| ); | ||
|
|
||
| expect(launched, false); | ||
| }); | ||
|
|
||
| test('closeWebView default behavior', () async { | ||
| await launcher.closeWebView(); | ||
| expect( | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@amirh do you have any comment on this version bump?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that for the null safety migration as we expect all platform implementations to get the same bump in close proximity it is reasonable to do a major bump on the platform interface.