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

Commit 2ab3044

Browse files
[url_launcher] Switch to new analysis options (#4551)
Removes the legacy analysis options for all `url_launcher` packages, and fixes all resulting violations. Most fixes are automatic `dart fix` changes. No version change: Most of these changes are to code that don't affect clients, or are clearly no-ops (e.g., adding a type specifier that was already strongly inferred). Only the packages where there is some potential for change—although none is actually expected—have version bumps. Part of flutter/flutter#76229
1 parent 3990aaf commit 2ab3044

File tree

50 files changed

+178
-144
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+178
-144
lines changed

packages/url_launcher/analysis_options.yaml

Lines changed: 0 additions & 1 deletion
This file was deleted.

packages/url_launcher/url_launcher/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 6.0.17
2+
3+
* Updates code for new analysis options.
4+
15
## 6.0.16
26

37
* Moves Android and iOS implementations to federated packages.

packages/url_launcher/url_launcher/example/lib/main.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ class MyApp extends StatelessWidget {
2222
theme: ThemeData(
2323
primarySwatch: Colors.blue,
2424
),
25-
home: MyHomePage(title: 'URL Launcher'),
25+
home: const MyHomePage(title: 'URL Launcher'),
2626
);
2727
}
2828
}
2929

3030
class MyHomePage extends StatefulWidget {
31-
MyHomePage({Key? key, required this.title}) : super(key: key);
31+
const MyHomePage({Key? key, required this.title}) : super(key: key);
3232
final String title;
3333

3434
@override
@@ -213,11 +213,11 @@ class _MyHomePageState extends State<MyHomePage> {
213213
uri: Uri.parse(
214214
'https://pub.dev/documentation/url_launcher/latest/link/link-library.html'),
215215
target: LinkTarget.blank,
216-
builder: (ctx, openLink) {
216+
builder: (BuildContext ctx, FollowLink? openLink) {
217217
return TextButton.icon(
218218
onPressed: openLink,
219-
label: Text('Link Widget documentation'),
220-
icon: Icon(Icons.read_more),
219+
label: const Text('Link Widget documentation'),
220+
icon: const Icon(Icons.read_more),
221221
);
222222
},
223223
),

packages/url_launcher/url_launcher/example/pubspec.yaml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,10 @@ dependencies:
1818
path: ../
1919

2020
dev_dependencies:
21-
integration_test:
22-
sdk: flutter
2321
flutter_driver:
2422
sdk: flutter
25-
pedantic: ^1.10.0
23+
integration_test:
24+
sdk: flutter
2625
mockito: ^5.0.0
2726
plugin_platform_interface: ^2.0.0
2827

packages/url_launcher/url_launcher/lib/link.dart

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

5-
export 'src/link.dart' show Link;
65
export 'package:url_launcher_platform_interface/link.dart'
76
show FollowLink, LinkTarget, LinkWidgetBuilder;
7+
8+
export 'src/link.dart' show Link;

packages/url_launcher/url_launcher/lib/src/link.dart

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,27 +43,31 @@ Future<ByteData> Function(Object?, String) pushRouteToFrameworkFunction =
4343
/// );
4444
/// ```
4545
class Link extends StatelessWidget implements LinkInfo {
46+
/// Creates a widget that renders a real link on the web, and uses WebViews in
47+
/// native platforms to open links.
48+
const Link({
49+
Key? key,
50+
required this.uri,
51+
this.target = LinkTarget.defaultTarget,
52+
required this.builder,
53+
}) : super(key: key);
54+
4655
/// Called at build time to construct the widget tree under the link.
56+
@override
4757
final LinkWidgetBuilder builder;
4858

4959
/// The destination that this link leads to.
60+
@override
5061
final Uri? uri;
5162

5263
/// The target indicating where to open the link.
64+
@override
5365
final LinkTarget target;
5466

5567
/// Whether the link is disabled or not.
68+
@override
5669
bool get isDisabled => uri == null;
5770

58-
/// Creates a widget that renders a real link on the web, and uses WebViews in
59-
/// native platforms to open links.
60-
Link({
61-
Key? key,
62-
required this.uri,
63-
this.target = LinkTarget.defaultTarget,
64-
required this.builder,
65-
}) : super(key: key);
66-
6771
LinkDelegate get _effectiveDelegate {
6872
return UrlLauncherPlatform.instance.linkDelegate ??
6973
DefaultLinkDelegate.create;
@@ -94,8 +98,12 @@ class DefaultLinkDelegate extends StatelessWidget {
9498
final LinkInfo link;
9599

96100
bool get _useWebView {
97-
if (link.target == LinkTarget.self) return true;
98-
if (link.target == LinkTarget.blank) return false;
101+
if (link.target == LinkTarget.self) {
102+
return true;
103+
}
104+
if (link.target == LinkTarget.blank) {
105+
return false;
106+
}
99107
return false;
100108
}
101109

packages/url_launcher/url_launcher/pubspec.yaml

Lines changed: 1 addition & 2 deletions
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/plugins/tree/master/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.0.16
6+
version: 6.0.17
77

88
environment:
99
sdk: ">=2.14.0 <3.0.0"
@@ -41,6 +41,5 @@ dev_dependencies:
4141
flutter_test:
4242
sdk: flutter
4343
mockito: ^5.0.0
44-
pedantic: ^1.10.0
4544
plugin_platform_interface: ^2.0.0
4645
test: ^1.16.3

packages/url_launcher/url_launcher/test/link_test.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
// found in the LICENSE file.
44

55
import 'package:flutter/material.dart';
6-
import 'package:flutter_test/flutter_test.dart';
76
import 'package:flutter/services.dart';
7+
import 'package:flutter_test/flutter_test.dart';
88
import 'package:url_launcher/link.dart';
99
import 'package:url_launcher/src/link.dart';
1010
import 'package:url_launcher_platform_interface/url_launcher_platform_interface.dart';
@@ -118,11 +118,11 @@ void main() {
118118
));
119119

120120
bool frameworkCalled = false;
121-
Future<ByteData> Function(Object?, String) originalPushFunction =
121+
final Future<ByteData> Function(Object?, String) originalPushFunction =
122122
pushRouteToFrameworkFunction;
123123
pushRouteToFrameworkFunction = (Object? _, String __) {
124124
frameworkCalled = true;
125-
return Future.value(ByteData(0));
125+
return Future<ByteData>.value(ByteData(0));
126126
};
127127

128128
await followLink!();

packages/url_launcher/url_launcher/test/url_launcher_test.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
import 'dart:async';
66
import 'dart:ui';
77

8-
import 'package:flutter_test/flutter_test.dart';
98
import 'package:flutter/foundation.dart';
9+
import 'package:flutter/services.dart' show PlatformException;
10+
import 'package:flutter_test/flutter_test.dart';
1011
import 'package:url_launcher/url_launcher.dart';
1112
import 'package:url_launcher_platform_interface/url_launcher_platform_interface.dart';
12-
import 'package:flutter/services.dart' show PlatformException;
1313

1414
import 'mock_url_launcher_platform.dart';
1515

@@ -239,7 +239,7 @@ void main() {
239239
..setResponse(true);
240240

241241
final TestWidgetsFlutterBinding binding =
242-
_anonymize(TestWidgetsFlutterBinding.ensureInitialized())
242+
_anonymize(TestWidgetsFlutterBinding.ensureInitialized())!
243243
as TestWidgetsFlutterBinding;
244244
debugDefaultTargetPlatformOverride = TargetPlatform.iOS;
245245
binding.renderView.automaticSystemUiAdjustment = true;
@@ -268,7 +268,7 @@ void main() {
268268
..setResponse(true);
269269

270270
final TestWidgetsFlutterBinding binding =
271-
_anonymize(TestWidgetsFlutterBinding.ensureInitialized())
271+
_anonymize(TestWidgetsFlutterBinding.ensureInitialized())!
272272
as TestWidgetsFlutterBinding;
273273
debugDefaultTargetPlatformOverride = TargetPlatform.android;
274274
expect(binding.renderView.automaticSystemUiAdjustment, true);
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## NEXT
2+
3+
* Updates code for new analysis options.
4+
15
## 6.0.13
26

37
* Splits from `shared_preferences` as a federated implementation.

0 commit comments

Comments
 (0)