New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migrate 104-complete to NNBD. #211
Migrate 104-complete to NNBD. #211
Conversation
super(key: key, listenable: listenable); | ||
|
||
final Animation<double> _listenable; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why was the type changed and no longer using the super's listenable anymore?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Super's listenable
has type Listenable
.
In this widget, listenable
is used as an Animation<double>
for its value
, so listenable
must be an Animation<double>
. Animation<double>
is a subclass of Listenable
.
If we use super's listenable
, then we must do a casting similar to
final Animation<double> animation = this.listenable;
on line 77 (before the change).
This also permits the user to pass in any Listenable
, including ones that don't have a value
, which breaks the widget. By restricting listenable
to Animation<double>
, we can ensure that the animation passed in by the user is valid, and all errors can be caught at compile-time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
██╗ ██████╗ ████████╗███╗ ███╗
██║ ██╔════╝ ╚══██╔══╝████╗ ████║
██║ ██║ ███╗ ██║ ██╔████╔██║
██║ ██║ ██║ ██║ ██║╚██╔╝██║
███████╗╚██████╔╝ ██║ ██║ ╚═╝ ██║
╚══════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝
No description provided.