Last active
November 21, 2022 10:38
-
-
Save marcel-ploch/35a166fcec1aecf4c4c6e5195ff84bcd to your computer and use it in GitHub Desktop.
Basis Typen Deklaration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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