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

Style guidelines for allowing implementing interfaces #382

Closed
pschiffmann opened this issue Sep 22, 2017 · 1 comment
Closed

Style guidelines for allowing implementing interfaces #382

pschiffmann opened this issue Sep 22, 2017 · 1 comment
Assignees
Labels
a.effective-dart Relates to the best practices explained in Effective Dart

Comments

@pschiffmann
Copy link

pschiffmann commented Sep 22, 2017

The Design / types section of the style guide gives recommendations when and how to extend or mixin classes from other packages. However, using implements on a class from another package can also lead to errors, if that package uses is expressions to guard accesses to protected class members.

I just encountered this problem while working with package:built_collection. I want to write a class that implements BuiltSet, but doing that would break this line.

I guess the only way to resolve this is

AVOID implementing a class that isn’t intended to be implemented.

The other option,

DO guard accesses to protected members with a obj.runtimeType == MyClass check

would solve the implements problem, but is unnecessarily restrictive in the extends case.

Best regards,
Philipp

@kwalrath kwalrath added the a.effective-dart Relates to the best practices explained in Effective Dart label Sep 22, 2017
@munificent munificent changed the title style guide: add recommendation when to implement 3rd party class interfaces Style guidelines for allowing implementing interfaces Apr 2, 2018
@munificent
Copy link
Member

Fixed in 6836e7d.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a.effective-dart Relates to the best practices explained in Effective Dart
Projects
None yet
Development

No branches or pull requests

3 participants