Skip to content

Instantly share code, notes, and snippets.

@chunhtai
Created May 14, 2020 22:01
Show Gist options
  • Save chunhtai/afa5e15eb1c0ba4829527ae185a9d780 to your computer and use it in GitHub Desktop.
Save chunhtai/afa5e15eb1c0ba4829527ae185a9d780 to your computer and use it in GitHub Desktop.
import 'dart:async';
void main() {
Tester a = Tester();
a.test();
}
class Tester {
Object _currentRouterDelegateTransaction;
void test() {
print('begin transaction $_currentRouterDelegateTransaction');
_createFuture()
.then<void>(_verifyRouteNameParserStillCurrent)
.then<void>(_verifyRouterDelegateStillCurrent(_currentRouterDelegateTransaction))
.then<void>((void data) {
print('should not reach here');
});
}
Future<void> _createFuture() {
return Future<void>.value(null);
}
Future<void> _verifyRouteNameParserStillCurrent(void data) {
_currentRouterDelegateTransaction = Object();
return Future<void>.value();
}
Function _verifyRouterDelegateStillCurrent(Object transaction) {
return (void data) {
// this should fail.
assert (transaction == _currentRouterDelegateTransaction);
return Future<void>.value();
};
}
}
typedef _AsyncPassthrough<Q> = Future<Q> Function(Q);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment