Skip to content

Commit 3fe6a01

Browse files
authored
[url_launcher] Fixes new unnecessary boolean operations warnings (#9409)
I had opened #9361 and messed up when rebasing the changes. That made the old PR get closed. CC @stuartmorgan-g for continuing the review. Description from the old PR: I'm fixing dart-lang/sdk#60614, which adds some other cases to `no_literal_bool_comparisons`, and these were triggered here. I'm unsure of the intended behaviour of the `packages\url_launcher\url_launcher\lib\src\legacy_api.dart` part, but I can fix it if the result wasn't intended this way (the operators' priority may be less known here). About the other cases with `|| true`, I think these might be a pattern from the team, so maybe adding a file ignore could also fix this. Please say so that I can make this the right way for you. ## Pre-Review Checklist [^1]: Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling.
1 parent 568e782 commit 3fe6a01

File tree

7 files changed

+21
-8
lines changed

7 files changed

+21
-8
lines changed

packages/in_app_purchase/in_app_purchase/example/lib/main.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ void main() {
2222

2323
// Auto-consume must be true on iOS.
2424
// To try without auto-consume on another platform, change `true` to `false` here.
25+
// ignore: no_literal_bool_comparisons
2526
final bool _kAutoConsume = Platform.isIOS || true;
2627

2728
const String _kConsumableId = 'consumable';

packages/rfw/test/argument_decoders_test.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// found in the LICENSE file.
44

55
// This file is hand-formatted.
6+
// ignore_for_file: no_literal_bool_comparisons
67

78
import 'dart:ui' as ui;
89

packages/rfw/test/material_widgets_test.dart

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5+
// ignore_for_file: no_literal_bool_comparisons
6+
57
import 'package:flutter/foundation.dart';
68
import 'package:flutter/gestures.dart';
79
import 'package:flutter/material.dart';
@@ -245,7 +247,7 @@ void main() {
245247
await expectLater(
246248
find.byType(RemoteWidget),
247249
matchesGoldenFile('goldens/material_test.drawer.png'),
248-
skip: !runGoldens,
250+
skip: !runGoldens || true,
249251
);
250252
});
251253

@@ -323,7 +325,7 @@ void main() {
323325
find.byType(RemoteWidget),
324326
matchesGoldenFile(
325327
'goldens/material_test.button_bar_properties.overflow.png'),
326-
skip: !runGoldens,
328+
skip: !runGoldens || true,
327329
);
328330
});
329331

@@ -450,7 +452,7 @@ void main() {
450452
await expectLater(
451453
find.byType(RemoteWidget),
452454
matchesGoldenFile('goldens/material_test.overflow_bar_properties.png'),
453-
skip: !runGoldens,
455+
skip: !runGoldens || true,
454456
);
455457

456458
// Update the surface size for OverflowBar to overflow.
@@ -524,7 +526,7 @@ void main() {
524526
await expectLater(
525527
find.byType(RemoteWidget),
526528
matchesGoldenFile('goldens/material_test.ink_response_hover.png'),
527-
skip: !runGoldens,
529+
skip: !runGoldens || true,
528530
);
529531
expect(eventLog, contains('onHover {}'));
530532

@@ -537,7 +539,7 @@ void main() {
537539
await expectLater(
538540
find.byType(RemoteWidget),
539541
matchesGoldenFile('goldens/material_test.ink_response_tap.png'),
540-
skip: !runGoldens,
542+
skip: !runGoldens || true,
541543
);
542544
await gesture.up();
543545
await tester.pump();

packages/url_launcher/url_launcher/CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
## NEXT
1+
## 6.3.2
22

33
* Updates README to indicate that Andoid SDK <21 is no longer supported.
44
* Updates minimum supported SDK version to Flutter 3.27/Dart 3.6.
5+
* Ensures that `launch` with `forceSafariVC: false`, `forceWebView: true` and a non-web scheme throws a `PlatformException`.
56

67
## 6.3.1
78

packages/url_launcher/url_launcher/lib/src/legacy_api.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ Future<bool> launch(
7878
final bool isWebURL =
7979
url != null && (url.scheme == 'http' || url.scheme == 'https');
8080

81-
if ((forceSafariVC ?? false || forceWebView) && !isWebURL) {
81+
if (((forceSafariVC ?? false) || forceWebView) && !isWebURL) {
8282
throw PlatformException(
8383
code: 'NOT_A_WEB_SCHEME',
8484
message: 'To use webview or safariVC, you need to pass '

packages/url_launcher/url_launcher/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ description: Flutter plugin for launching a URL. Supports
33
web, phone, SMS, and email schemes.
44
repository: https://github.com/flutter/packages/tree/main/packages/url_launcher/url_launcher
55
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+url_launcher%22
6-
version: 6.3.1
6+
version: 6.3.2
77

88
environment:
99
sdk: ^3.6.0

packages/url_launcher/url_launcher/test/src/legacy_api_test.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,14 @@ void main() {
229229
throwsA(isA<PlatformException>()));
230230
});
231231

232+
test('cannot send e-mail with forceSafariVC: false and forceWebView: true',
233+
() async {
234+
expect(
235+
() async => launch('mailto:[email protected]?subject=Hello',
236+
forceSafariVC: false, forceWebView: true),
237+
throwsA(isA<PlatformException>()));
238+
});
239+
232240
test('controls system UI when changing statusBarBrightness', () async {
233241
mock
234242
..setLaunchExpectations(

0 commit comments

Comments
 (0)