From dbe168bd22ea767bd4f357fcc671096f9cdba4a1 Mon Sep 17 00:00:00 2001 From: Eric Seidel Date: Tue, 10 Oct 2023 08:36:55 -0700 Subject: [PATCH 1/2] docs: Add a warning about dart-lang/sdk#43763 to sortedBy --- lib/src/iterable_extensions.dart | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lib/src/iterable_extensions.dart b/lib/src/iterable_extensions.dart index 1bf4b3e..7b6bef2 100644 --- a/lib/src/iterable_extensions.dart +++ b/lib/src/iterable_extensions.dart @@ -72,6 +72,22 @@ extension IterableExtension on Iterable { /// /// The elements are ordered by the natural ordering of the /// property [keyOf] of the element. + /// + /// Due to https://github.com/dart-lang/sdk/issues/43763 + /// if you are comparing using int, you will need to use the type + /// annotation instead, e.g. + /// + /// ```dart + /// class Foo { + /// final int bar; + /// Foo(this.bar); + /// } + /// + /// final foos = [Foo(1), Foo(2), Foo(3)]; + /// // final sortedFoos = foos.sortedBy((foo) => foo.bar); // Error + /// final sortedFoos = foos.sortedBy((foo) => foo.bar as num); // Works + /// final alsoWorks = foos.sortedBy((foo) => foo.bar); // Works + /// ``` List sortedBy>(K Function(T element) keyOf) { var elements = [...this]; mergeSortBy(elements, keyOf, compareComparable); From 4078f903d73d30e499b30537d8ff12c117ea196f Mon Sep 17 00:00:00 2001 From: Eric Seidel Date: Tue, 10 Oct 2023 08:46:54 -0700 Subject: [PATCH 2/2] fix to --- lib/src/iterable_extensions.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/iterable_extensions.dart b/lib/src/iterable_extensions.dart index 7b6bef2..66c35f6 100644 --- a/lib/src/iterable_extensions.dart +++ b/lib/src/iterable_extensions.dart @@ -74,7 +74,7 @@ extension IterableExtension on Iterable { /// property [keyOf] of the element. /// /// Due to https://github.com/dart-lang/sdk/issues/43763 - /// if you are comparing using int, you will need to use the type + /// if you are comparing using int, you will need to use the `num` type /// annotation instead, e.g. /// /// ```dart