Skip to content

Instantly share code, notes, and snippets.

@heyhey1028
Last active November 11, 2022 03:25
Show Gist options
  • Save heyhey1028/dfad34a15198cddb76ed36b6bf4c0119 to your computer and use it in GitHub Desktop.
Save heyhey1028/dfad34a15198cddb76ed36b6bf4c0119 to your computer and use it in GitHub Desktop.
Extensions for Flutter Projects

Extensions for Flutter Projects

extension StreamEx<T> on Stream<T> {
Stream<T> onlyNotify(
bool Function(T? previousEvent, T currentEvent) test,
) async* {
T? previousEvent;
await for (final event in this) {
if (test(previousEvent, event)) {
yield event;
}
previousEvent = event;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment