Created with <3 with dartpad.dev.
Last active
September 10, 2022 18:31
-
-
Save mdrideout/9b55eab93919d3c19733157f3c7825ca to your computer and use it in GitHub Desktop.
solar-arc-1468
This file contains hidden or 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 Author { | |
final String id; | |
final String handle; | |
String name; | |
Author({ | |
required this.id, | |
required this.handle, | |
required this.name, | |
}); | |
void setName(String newName) { | |
name = newName; | |
} | |
get getName => name; | |
} | |
void main() { | |
Map<String, Author?> authorCache = {}; | |
Author sampleAuthor = Author( | |
id: "zxcvbnm", | |
handle: "goodauthor", | |
name: "Arthur McAuthor", | |
); | |
authorCache['zxcvbnm'] = sampleAuthor; | |
authorCache['goodauthor'] = sampleAuthor; | |
sampleAuthor.setName("New Name"); | |
print(authorCache['zxcvbnm']?.getName); | |
print(authorCache['goodauthor']?.getName); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment