• Ian Hickson's avatar
    Support chaining await calls on controllers (#9389) · 14e728d0
    Ian Hickson authored
    With this patch, you can do:
    
    ```dart
       Future<Null> foo() async {
         try {
           await controller.forward().orCancel;
           await controller.reverse().orCancel;
           await controller.forward().orCancel;
         } on TickerCanceled {
           // did not complete
         }
       }
    ```
    
    ...in a State's async method, and so long as you dispose of the
    controller properly in your dispose, you'll have a nice way of doing
    animations in sequence without leaking the controller. try/finally
    works as well, if you need to allocate resources and discard them when
    canceled.
    
    Simultaneously, you can do:
    
    ```dart
       Future<Null> foo() async {
         await controller.forward().orCancel;
         await controller.reverse().orCancel;
         await controller.forward().orCancel;
       }
    ```
    
    ...and have the same effect, where the method will just silently hang
    (and get GC'ed) if the widget is disposed, without leaking anything,
    if you don't need to catch the controller being killed.
    
    And all this, without spurious errors for uncaught exceptions on
    controllers.
    14e728d0
Name
Last commit
Last update
.idea Loading commit data...
bin Loading commit data...
dev Loading commit data...
examples Loading commit data...
packages Loading commit data...
.analysis_options Loading commit data...
.analysis_options_repo Loading commit data...
.gitattributes Loading commit data...
.gitignore Loading commit data...
.travis.yml Loading commit data...
AUTHORS Loading commit data...
CONTRIBUTING.md Loading commit data...
ISSUE_TEMPLATE.md Loading commit data...
LICENSE Loading commit data...
PATENTS Loading commit data...
README.md Loading commit data...
VERSION Loading commit data...
appveyor.yml Loading commit data...