Last active
June 23, 2020 09:20
-
-
Save aryzae/d436444f2f7b4332fb8da331034ad514 to your computer and use it in GitHub Desktop.
Flutter勉強会3回目の資料(クラス)
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
void main() { | |
// instance | |
Sample sample = Sample('Hello Dart World!'); | |
sample.speakPublicMessage(); | |
sample.setPrivateMessage('Goodbye Native World.'); | |
sample.speakPrivateMessage(); | |
} | |
// classの定義 | |
class Sample { | |
// constructor | |
Sample(this.publicMessage); | |
// public field | |
String publicMessage; | |
// private field | |
String _privateMessage; | |
// method | |
void setPrivateMessage(String newValue) => _privateMessage = newValue; | |
void speakPublicMessage() { | |
print(publicMessage); | |
} | |
void speakPrivateMessage() { | |
print(_privateMessage); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment