Skip to content

Instantly share code, notes, and snippets.

@rikuTanide rikuTanide/state1.dart
Last active Oct 12, 2017

Embed
What would you like to do?
状態変数にいろんなところからアクセスしている
bool aisatu = false;
int onigiriPrice = 100;
void onMessage(String message) {
switch (message) {
case "こんにちは":
onAisatu();
return;
case "おにぎり3個ください":
onOnigiriRequest();
return;
}
}
void onAisatu() {
print("こんにちは");
aisatu = true;
}
void onOnigiriRequest() {
if (aisatu) {
var sum = onigiriPrice * 3;
print("$sum 円です");
aisatu = false;
}
}
void setOnigiriPrice(int price) {
onigiriPrice = price;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.