Skip to content

Commit

Permalink
✨ Switch to NNBD (Dart 2.12)
Browse files Browse the repository at this point in the history
#time: 3 hours 56 minutes
  • Loading branch information
devkabiir committed Mar 27, 2021
1 parent 46fbab5 commit c865750
Show file tree
Hide file tree
Showing 7 changed files with 610 additions and 464 deletions.
13 changes: 5 additions & 8 deletions lib/composition.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'dart:async';

import 'inheritable.dart';

bool _equals({Object prev, Object next}) {
bool _equals({required Object? prev, required Object? next}) {
return next != prev;
}

Expand All @@ -25,19 +25,16 @@ PredicateAspect<T> debounce<T>(
PredicateAspect<T> shouldNotify = _equals,
bool leading = false,
}) {
assert(leading != null);
assert(shouldNotify != null);
assert(duration != null);
bool _exhausted = false;
T _lastValue;
T? _lastValue;

Timer timer;
Timer? timer;
void stop() {
_exhausted = true;
timer = null;
}

return ({T prev, T next}) {
return ({required T prev, required T next}) {
_lastValue ??= leading ? next : prev;

/// After notifying for leading change, stop notifying for it
Expand All @@ -58,7 +55,7 @@ PredicateAspect<T> debounce<T>(
// Allows restarting timer for next run
_exhausted = false;

if (shouldNotify(next: next, prev: _lastValue)) {
if (shouldNotify(next: next, prev: _lastValue!)) {
_lastValue = next;
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/extensions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'package:flutter/widgets.dart';
import 'inheritable.dart';

extension BoolAspectOf<T> on Aspect<bool, T> {
Aspect<R, T> map<R>({R onTrue, R onFalse, Key key}) {
Aspect<R, T> map<R>({required R onTrue, required R onFalse, Key? key}) {
return AspectChianingFn(this).map(
(b) => b ? onTrue : onFalse,
key,
Expand Down
Loading

0 comments on commit c865750

Please sign in to comment.