diff --git a/app/lib/admin/tools/delete_all_staging.dart b/app/lib/admin/tools/delete_all_staging.dart index 39870b2eae..8f6b37c533 100644 --- a/app/lib/admin/tools/delete_all_staging.dart +++ b/app/lib/admin/tools/delete_all_staging.dart @@ -87,7 +87,7 @@ Future _batchedQuery( void flush() { if (keys.isEmpty) return; - fn(List.from(keys)); + fn(List.of(keys)); keys.clear(); budget = _defaultBudget; } diff --git a/app/lib/frontend/handlers/account.dart b/app/lib/frontend/handlers/account.dart index f0efb13ee5..ea16bfddd2 100644 --- a/app/lib/frontend/handlers/account.dart +++ b/app/lib/frontend/handlers/account.dart @@ -203,9 +203,10 @@ Future listPackageLikesHandler( final authenticatedUser = await requireAuthenticatedWebUser(); final user = authenticatedUser.user; final packages = await likeBackend.listPackageLikes(user); - final List packageLikes = List.from(packages.map( - (like) => PackageLikeResponse( - liked: true, package: like.package, created: like.created))); + final List packageLikes = packages + .map((like) => PackageLikeResponse( + liked: true, package: like.package, created: like.created)) + .toList(); return LikedPackagesResponse(likedPackages: packageLikes); } diff --git a/app/lib/frontend/handlers/custom_api.dart b/app/lib/frontend/handlers/custom_api.dart index 795d4a78b1..747f971836 100644 --- a/app/lib/frontend/handlers/custom_api.dart +++ b/app/lib/frontend/handlers/custom_api.dart @@ -461,8 +461,7 @@ Future apiSearchHandler(shelf.Request request) async { if (sr.errorMessage != null) 'message': sr.errorMessage, }; if (hasNextPage) { - final newParams = - Map.from(request.requestedUri.queryParameters); + final newParams = {...request.requestedUri.queryParameters}; newParams['page'] = (searchForm.currentPage! + 1).toString(); final nextPageUrl = request.requestedUri.replace(queryParameters: newParams).toString(); diff --git a/app/lib/frontend/static_files.dart b/app/lib/frontend/static_files.dart index e752d3db5d..c253742edc 100644 --- a/app/lib/frontend/static_files.dart +++ b/app/lib/frontend/static_files.dart @@ -200,7 +200,7 @@ class StaticFileCache { String get etag => _etag ??= _calculateEtagOfEtags().substring(0, 8); String _calculateEtagOfEtags() { - final files = List.from(_files.values); + final files = _files.values.toList(); files.sort((a, b) => a.requestPath.compareTo(b.requestPath)); final concatenatedEtags = files.map((f) => f.etag).join(' '); final digest = crypto.sha256.convert(utf8.encode(concatenatedEtags)); @@ -402,8 +402,7 @@ class ParsedStaticUrl { factory ParsedStaticUrl.parse(Uri requestedUri) { final normalizedRequestPath = path.normalize(requestedUri.path); - final pathSegments = - List.from(Uri(path: normalizedRequestPath).pathSegments); + final pathSegments = List.of(Uri(path: normalizedRequestPath).pathSegments); String? pathHash; var filePath = normalizedRequestPath; if (pathSegments.length > 2 && pathSegments[1].startsWith('hash-')) { diff --git a/app/lib/search/models.dart b/app/lib/search/models.dart index bf20e059d4..8d50dc79f9 100644 --- a/app/lib/search/models.dart +++ b/app/lib/search/models.dart @@ -3,6 +3,7 @@ // BSD-style license that can be found in the LICENSE file. import 'package:clock/clock.dart'; +import 'package:collection/collection.dart'; import 'package:json_annotation/json_annotation.dart'; import 'package:pub_dev/shared/popularity_storage.dart'; @@ -59,8 +60,7 @@ extension UpdateLikesExt on Iterable { /// The score is normalized into the range of [0.0 - 1.0] using the /// ordered list of packages by like counts (same like count gets the same score). void updateLikeScores() { - final sortedByLikes = List.from(this) - ..sort((a, b) => a.likeCount.compareTo(b.likeCount)); + final sortedByLikes = sorted((a, b) => a.likeCount.compareTo(b.likeCount)); for (var i = 0; i < sortedByLikes.length; i++) { if (i > 0 && sortedByLikes[i - 1].likeCount == sortedByLikes[i].likeCount) { diff --git a/app/lib/search/search_service.dart b/app/lib/search/search_service.dart index 9c21b97720..d2e471cb51 100644 --- a/app/lib/search/search_service.dart +++ b/app/lib/search/search_service.dart @@ -128,7 +128,7 @@ class PackageDocument { Map toJson() => _$PackageDocumentToJson(this); @JsonKey(includeFromJson: false, includeToJson: false) - late final tagsForLookup = Set.from(tags); + late final Set tagsForLookup = Set.of(tags); } /// A reference to an API doc page diff --git a/app/lib/service/youtube/backend.dart b/app/lib/service/youtube/backend.dart index b5d19d56bb..d6624a36c2 100644 --- a/app/lib/service/youtube/backend.dart +++ b/app/lib/service/youtube/backend.dart @@ -82,7 +82,7 @@ class YoutubeBackend { /// Algorithm description at [YoutubeBackend.getTopPackageOfWeekVideos]. @visibleForTesting List selectRandomVideos(math.Random random, List source, int count) { - final selectable = List.from(source); + final selectable = List.of(source); final selected = []; while (selected.length < count && selectable.isNotEmpty) { if (selected.isEmpty) { diff --git a/app/lib/shared/configuration.dart b/app/lib/shared/configuration.dart index af3a13411c..6d01715240 100644 --- a/app/lib/shared/configuration.dart +++ b/app/lib/shared/configuration.dart @@ -5,7 +5,6 @@ import 'dart:convert' show json; import 'dart:io'; -import 'package:collection/collection.dart' show UnmodifiableSetView; import 'package:gcloud/service_scope.dart' as ss; import 'package:json_annotation/json_annotation.dart'; import 'package:meta/meta.dart'; @@ -455,7 +454,7 @@ class AdminId { required this.oauthUserId, required this.email, required Iterable permissions, - }) : permissions = UnmodifiableSetView(Set.from(permissions)); + }) : permissions = Set.unmodifiable(permissions.nonNulls); factory AdminId.fromJson(Map json) => _$AdminIdFromJson(json); diff --git a/app/lib/shared/markdown.dart b/app/lib/shared/markdown.dart index a63ef6c19b..c16867f4e0 100644 --- a/app/lib/shared/markdown.dart +++ b/app/lib/shared/markdown.dart @@ -318,7 +318,7 @@ String _rewriteAbsoluteUrl(String url) { if (uri.host == 'github.com') { final segments = uri.pathSegments; if (segments.length > 3 && segments[2] == 'blob') { - final newSegments = List.from(segments); + final newSegments = List.of(segments); newSegments[2] = 'raw'; return uri.replace(pathSegments: newSegments).toString(); } diff --git a/app/lib/shared/urls.dart b/app/lib/shared/urls.dart index 97055b8d22..7da3590449 100644 --- a/app/lib/shared/urls.dart +++ b/app/lib/shared/urls.dart @@ -398,7 +398,7 @@ String? getRepositoryUrl( } try { final uri = Uri.parse(repository!); - final segments = List.from(uri.pathSegments); + final segments = List.of(uri.pathSegments); while (segments.isNotEmpty && segments.last.isEmpty) { segments.removeLast(); } diff --git a/app/lib/shared/utils.dart b/app/lib/shared/utils.dart index 20f64f62f7..f5a2235986 100644 --- a/app/lib/shared/utils.dart +++ b/app/lib/shared/utils.dart @@ -137,7 +137,7 @@ class LastNTracker> { T? _getP(double p) { if (_lastItems.isEmpty) return null; - final List list = List.from(_lastItems); + final List list = _lastItems.toList(); list.sort(); return list[(list.length * p).floor()]; } diff --git a/app/lib/task/cloudcompute/googlecloudcompute.dart b/app/lib/task/cloudcompute/googlecloudcompute.dart index d7fcf60b6b..e9366bf582 100644 --- a/app/lib/task/cloudcompute/googlecloudcompute.dart +++ b/app/lib/task/cloudcompute/googlecloudcompute.dart @@ -358,7 +358,7 @@ class _GoogleCloudCompute extends CloudCompute { ); @override - List get zones => List.from(_zones); + List get zones => List.of(_zones); @override String generateInstanceName() => 'worker-${Ulid()}'; diff --git a/pkg/fake_gcloud/lib/mem_datastore.dart b/pkg/fake_gcloud/lib/mem_datastore.dart index 7364889c57..e67af2280f 100644 --- a/pkg/fake_gcloud/lib/mem_datastore.dart +++ b/pkg/fake_gcloud/lib/mem_datastore.dart @@ -21,7 +21,7 @@ class MemDatastore implements Datastore { Future> allocateIds(List keys) async { return keys.map((k) { if (k.elements.last.id == null) { - final elements = List.from(k.elements); + final elements = List.of(k.elements); final last = elements.removeLast(); elements.add(KeyElement(last.kind, _unusedId++)); return Key(elements, partition: k.partition);