Skip to content

Generative enums don't work if used alongside const constructors of classes #2256

Open
@srikrsna

Description

@srikrsna

The code snippet below doesn't work,

enum Gaps {
  one(6);

  final SizedBox vBox, hBox, box;
  final double size;
  const Gaps(this.size)
      : box = const SizedBox(width: size, height: size),
        hBox = const SizedBox(width: size),
        vBox = const SizedBox(height: size);
}

It doesn't recognize size as constant. Am I missing something here because as far as I understand it is only possible to use generative enums with const values.

Metadata

Metadata

Assignees

No one assigned

    Labels

    requestRequests to resolve a particular developer problem

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions