-
Notifications
You must be signed in to change notification settings - Fork 207
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
A syntax for type signatures with mixins #1481
Comments
You are asking for intersection types: If you could use a term like class IndentedLine {
Widget & Indented child;
} Intersection types could be added to Dart, but it is likely to be a major project. In particular, intersection types are directly related to union types (for instance, using See #83 and #145 for further discussions about intersection and union types. Also note #1152 where the topic of intersection types is approached from a similar angle as in this issue. I'll close this issue as a duplicate of those other discussions. However, in the particular case where you wish to specify a subtype of class IndentedLine {
Indented child;
} |
Oh cool, I didn't know about I ended up using runtime type checking (and if anything that doesn't implement Indent is passed in, it just defaults to indent:0), but it's nice to know that there's a way to do that. |
Ah, makes sense! Thanks. |
It is sometimes desirable to require a parameter to implement a class and a mixin, for instance:
But the expression
Widget with Indented
is not legal. There is no way to refer to that type.I have tried
But this wont do here. When you actually create an IndentedWidget, you generally can't do it by extending IndentedWidget. You do it by extending
StatelessWidget with Indented
, which despite implementing both Widget and Indented, is not castable toIndentedWidget
.The text was updated successfully, but these errors were encountered: