• 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
positioned_test.dart 4.01 KB