Created
January 18, 2020 21:33
-
-
Save dolpheen/de8dbf032b1a9dfce330c5e469ef7d93 to your computer and use it in GitHub Desktop.
Dart Internals - Getters Setters VM Example
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 A { | |
String prop; | |
} | |
class B { | |
String _prop; | |
String get prop => _prop; | |
set prop(String value)=>_prop = value; | |
} | |
class C { | |
String get prop => 'Prop from C!'; | |
} | |
void main(){ | |
var a = A(); | |
a.prop = 'propA'; | |
print(a.prop); | |
var b = B(); | |
b.prop = 'propB'; | |
print(b.prop); | |
var c = C(); | |
print(c.prop); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment