Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

[url_launcher] Fix PlatformException introduced in nnbd release #3333

Merged
merged 7 commits into from
Feb 9, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/url_launcher/url_launcher/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 6.0.0-nullsafety.2

* Fix PlatformException when not specifying `forceSafariVC` for non-web URLs

## 6.0.0-nullsafety.1

* Bump Dart SDK to support null safety.
Expand Down
2 changes: 1 addition & 1 deletion packages/url_launcher/url_launcher/lib/url_launcher.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ import 'package:url_launcher_platform_interface/url_launcher_platform_interface.
/// is set to true and the universal link failed to launch.
Future<bool> launch(
String urlString, {
bool forceSafariVC = true,
bool forceSafariVC = false,
Copy link

@blasten blasten Jan 13, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any chance we can add a test? It could be as simple as just calling launch('<some-url', forceWebView: true) and asserting that it doesn't throw as well as one that does throw.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@blasten
I've commited the tests.
Also found out that the test 'default behavior' needed an update, because it expected useSafariVC = true.

Copy link
Contributor Author

@nohli nohli Jan 14, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, the example still has sdk constraints which don't enable nnbd, so flutter analyze gives the following output:

  error • This requires the 'non-nullable' language feature to be enabled •
         example/lib/main.dart:30:18 • experiment_not_enabled
  error • The parameter type 'dynamic' is incompatible with the field type
         'String' • example/lib/main.dart:30:25 •
         field_initializing_formal_not_assignable
  error • required isn't a type • example/lib/main.dart:30:25 • not_a_type
  error • This requires the 'non-nullable' language feature to be enabled •
         example/lib/main.dart:38:15 • experiment_not_enabled

Btw. analysis_options.yaml has:

analyzer:
  enable-experiment:
    - non-nullable

which is not necessary any more.

Should I also change both things?

edit: I had to comment out flutter: ">=1.12.13+hotfix.5" in pubspec.yaml for flutter analyze to give no error. Don't know if this is good.

bool forceWebView = false,
bool enableJavaScript = false,
bool enableDomStorage = false,
Expand Down
2 changes: 1 addition & 1 deletion packages/url_launcher/url_launcher/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: url_launcher
description: Flutter plugin for launching a URL on Android and iOS. Supports
web, phone, SMS, and email schemes.
homepage: https://github.com/flutter/plugins/tree/master/packages/url_launcher/url_launcher
version: 6.0.0-nullsafety.1
version: 6.0.0-nullsafety.2

flutter:
plugin:
Expand Down