Skip to content

Instantly share code, notes, and snippets.

@aryzae
Last active June 23, 2020 09:20
Show Gist options
  • Save aryzae/d436444f2f7b4332fb8da331034ad514 to your computer and use it in GitHub Desktop.
Save aryzae/d436444f2f7b4332fb8da331034ad514 to your computer and use it in GitHub Desktop.
Flutter勉強会3回目の資料(クラス)
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