Skip to content
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

Merged

Conversation

pennzht
Copy link
Contributor

@pennzht pennzht commented Oct 14, 2020

No description provided.

super(key: key, listenable: listenable);

final Animation<double> _listenable;
Copy link

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?

Copy link
Contributor Author

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.

Copy link

@JoseAlba JoseAlba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

██╗      ██████╗ ████████╗███╗   ███╗
██║     ██╔════╝ ╚══██╔══╝████╗ ████║
██║     ██║  ███╗   ██║   ██╔████╔██║
██║     ██║   ██║   ██║   ██║╚██╔╝██║
███████╗╚██████╔╝   ██║   ██║ ╚═╝ ██║
╚══════╝ ╚═════╝    ╚═╝   ╚═╝     ╚═╝

@pennzht pennzht merged commit 1700d3c into material-components:nnbd-104-complete Oct 16, 2020
@pennzht pennzht deleted the nnbd-104-dev-manual branch October 16, 2020 14:19
johnsonmh added a commit that referenced this pull request May 12, 2021
* Migrate 104-complete to NNBD. (#211)

Migrate 104-complete to NNBD. (#211)

* Update pubspec.yaml. (#213)

* Migrate 104-complete to NNBD (#218)

* Update intl version.

* Update SDK version.

* Remove `!`.

* Remove analysis_options.yaml.

Co-authored-by: Tianguang <penn.zht@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants