From c8dff9d6f6b62f22094489cc8597d57aa996e32b Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Tue, 15 Nov 2022 20:12:25 -0800 Subject: [PATCH] Revert change to Optional Breaks too many things --- CHANGELOG.md | 1 - lib/src/core/optional.dart | 9 +++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 33f414f2..e6bd2455 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,5 @@ #### 3.2.0-dev - * Explicitly disallow a `nullable` type argument for `Optional`. * Expose `TreeIterator` for iterating `TreeSet` instead of using `BidirectionalIterator`. * Require Dart 2.17 diff --git a/lib/src/core/optional.dart b/lib/src/core/optional.dart index 42ab9e51..ec1e98c6 100644 --- a/lib/src/core/optional.dart +++ b/lib/src/core/optional.dart @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +// ignore_for_file: null_check_on_nullable_type_parameter + import 'dart:collection'; /// A value that might be absent. @@ -23,7 +25,7 @@ import 'dart:collection'; /// With the introduction of non-null by default in Dart SDK 2.12, developers /// should avoid adding more uses of this type. Existing users should migrate /// away from the `Optional` type to types marked nullable: `T?`. -class Optional extends IterableBase { +class Optional extends IterableBase { /// Constructs an empty Optional. const Optional.absent() : _value = null; @@ -90,7 +92,7 @@ class Optional extends IterableBase { /// If the Optional is [absent()], returns [absent()] without applying the transformer. /// /// The transformer must not return [null]. If it does, an [ArgumentError] is thrown. - Optional transform(S Function(T value) transformer) { + Optional transform(S Function(T value) transformer) { return _value == null ? Optional.absent() : Optional.of(transformer(_value!)); @@ -101,8 +103,7 @@ class Optional extends IterableBase { /// If the Optional is [absent()], returns [absent()] without applying the transformer. /// /// Returns [absent()] if the transformer returns [null]. - Optional transformNullable( - S? Function(T value) transformer) { + Optional transformNullable(S? Function(T value) transformer) { return _value == null ? Optional.absent() : Optional.fromNullable(transformer(_value!));