Skip to content

Make it easier to use chains of "await"s with animation controllers in widgets #5236

@Hixie

Description

@Hixie

Consider the following code:

Future<Null> fadeOutAndUpdateState() async {
   await fadeAnimationController.reverse();
   if (!mounted)
     return;
   await sizeAnimationController.reverse();
   if (!mounted)
     return;
   setState(() {
     dismissed = true;
   });
 }

...it would be nice if the "if (!mounted)" calls weren't needed, but right now they are.

One option would be to make controllers complete with an error when they are aborted (or maybe only when disposed?). That would abort the above function. Unfortunately then you'd have to have a function to wrap the call site of the above function to handle (and ignore) the resulting error in the future...

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions