Skip to content

Instantly share code, notes, and snippets.

@marcel-ploch
Last active November 21, 2022 10:38
Show Gist options
  • Save marcel-ploch/35a166fcec1aecf4c4c6e5195ff84bcd to your computer and use it in GitHub Desktop.
Save marcel-ploch/35a166fcec1aecf4c4c6e5195ff84bcd to your computer and use it in GitHub Desktop.
Basis Typen Deklaration
class User {
String name;
String type;
User({required this.name, required this.type});
}
enum MyEnum {
foo("test", "admin"),
bar("test2", "user");
final String enumName;
final String type;
const MyEnum(this.enumName, this.type);
@override
String toString() {
return '${this.enumName} ${this.type}';
}
String toName() {
return this.name;
}
int get _name {
return this.index;
}
}
void main() {
var u = User(name: "test", type: "admin");
print(MyEnum.foo.name);
print(MyEnum.values);
print(MyEnum.foo.toString());
print(MyEnum.foo.toName());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment