google / google/built_value.dart

final params in Enum

Open
#1,093 5 comments 0 reactions 1 assignee Claimed by @davidmorgan View on GitHub
p2 / feature request
Dominant language
Dart
Stars
886
Forks
195
Avg merge
1d 11h
Merged PRs (30d)
4

Description

I am getting below error when trying to use final parameters in enum and trying to generate code

Please make the following changes to use EnumClass:
1. Have exactly one constructor: const Environments._(String name) : super(name);
2. Add method: static Environments valueOf(String name) => _$valueOf(name)

```
import 'package:built_collection/built_collection.dart';
import 'package:built_value/built_value.dart';
import 'package:built_value/serializer.dart';

part 'environments.g.dart';

class Environments extends EnumClass {
static Serializer get serializer => _$environmentsSerializer;

static BuiltSet get values => _$values;

static Environments valueOf(final String name) => _$valueOf(name);

static const Environments localhost = _$localhost;
static const Environments development = _$development;
@BuiltValueEnumConst(fallback: true)
static const Environments production = _$production;

const Environments._(final String name) : super(name);
}

```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.