Skip to content

Allow const constructor with mixins that have getter-only fields #37810

@cpboyd

Description

@cpboyd

Originally posted at google/built_value.dart#694

I'm getting const_constructor_with_mixin_with_field when using this mixin:

mixin RouteEnum on EnumClass {
  String get title;

  String get subtitle;

  IconData get icon;

  Color get color;
}

I have other code in the mixin that depends on those fields, which are defined in the subclass.

Since I'm not actually defining any fields in the mixin itself, it seems like this error shouldn't necessarily happen.

Shouldn't getter-only fields be treated similarly to functions?

Edit: Forgot to add my use case for this...
I'm using Flutter with a BottomNavigationBar and separate navigation within each tab.

As a result, I'd like to keep all of this related information with the EnumClass because it makes more sense structurally to me than to have functions within the various Widgets.

Metadata

Metadata

Assignees

Labels

legacy-area-analyzerUse area-devexp instead.type-bugIncorrect behavior (everything from a crash to more subtle misbehavior)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions