Skip to content

Commit 9a31dc1

Browse files
authored
Remove unnecessary imports of 'package:collection' IterableExtension (#3639)
* Replace `.whereNotNull()` with `.nonNulls` which is now in Dart core. * `.firstOrNull`, `.lastOrNull`, `.singleOrNull` and `.elementAtOrNull(i)` are also in Dart core and even under the same name, so simply drop the import of 'package:collection' whenever possible.
1 parent f895c61 commit 9a31dc1

File tree

3 files changed

+3
-5
lines changed

3 files changed

+3
-5
lines changed

lib/src/model/directives/categorization.dart

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

5-
import 'package:collection/collection.dart';
65
import 'package:dartdoc/src/model/model.dart';
76
import 'package:meta/meta.dart';
87

@@ -63,7 +62,7 @@ mixin Categorization on DocumentationComment implements Indexable {
6362

6463
@visibleForTesting
6564
List<Category> get categories => [
66-
...?categoryNames?.map((n) => package.nameToCategory[n]).whereNotNull()
65+
...?categoryNames?.map((n) => package.nameToCategory[n]).nonNulls
6766
]..sort();
6867

6968
Iterable<Category> get displayedCategories {

lib/src/model/model_element.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -670,8 +670,7 @@ abstract class ModelElement extends Canonicalization
670670
var getterDeprecated = pie.getter?.metadata.any((a) => a.isDeprecated);
671671
var setterDeprecated = pie.setter?.metadata.any((a) => a.isDeprecated);
672672

673-
var deprecatedValues =
674-
[getterDeprecated, setterDeprecated].whereNotNull();
673+
var deprecatedValues = [getterDeprecated, setterDeprecated].nonNulls;
675674

676675
// At least one of these should be non-null. Otherwise things are weird
677676
assert(deprecatedValues.isNotEmpty);

lib/src/special_elements.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ enum SpecialClass {
6060
/// Given an SDK, resolve URIs for the libraries containing our special
6161
/// classes.
6262
Set<String> specialLibraryFiles(DartSdk sdk) =>
63-
SpecialClass.values.map((e) => e._path(sdk)).whereNotNull().toSet();
63+
SpecialClass.values.map((e) => e._path(sdk)).nonNulls.toSet();
6464

6565
/// Class for managing special [Class] objects inside Dartdoc.
6666
class SpecialClasses {

0 commit comments

Comments
 (0)