Skip to content

Commit

Permalink
Resolve null safety migration TODOS (dart-archive/async#135)
Browse files Browse the repository at this point in the history
- Switch from `StackTrace.fromString` to `AsyncError.defaultStackTrace`.
- Remove a TODO about non-nullable `StackTrace`, by the time we merged
  null safety the type was already non-nullable and the TODO was stale.

Style tweak - remove the argument names from a Function type that are
redundant against their type names.
natebosch authored Aug 26, 2020
1 parent 75334af commit 34705a5
Showing 2 changed files with 2 additions and 7 deletions.
3 changes: 1 addition & 2 deletions pkgs/async/lib/src/result/error.dart
Original file line number Diff line number Diff line change
@@ -25,8 +25,7 @@ class ErrorResult implements Result<Never> {
ErrorResult get asError => this;

ErrorResult(this.error, [StackTrace? stackTrace])
// TODO: Use AsyncError.defaultStackTrace(error) once available
: stackTrace = stackTrace ?? StackTrace.fromString('');
: stackTrace = stackTrace ?? AsyncError.defaultStackTrace(error);

@override
void complete(Completer completer) {
Original file line number Diff line number Diff line change
@@ -11,11 +11,7 @@ import '../delegate/stream_sink.dart';
typedef HandleData<S, T> = void Function(S data, EventSink<T> sink);

/// The type of the callback for handling error events.
//
// TODO: Update to take a non-nullable StackTrace once that change lands in
// the sdk.
typedef HandleError<T> = void Function(
Object error, StackTrace stackTrace, EventSink<T> sink);
typedef HandleError<T> = void Function(Object error, StackTrace, EventSink<T>);

/// The type of the callback for handling done events.
typedef HandleDone<T> = void Function(EventSink<T> sink);

0 comments on commit 34705a5

Please sign in to comment.