Skip to content

Instantly share code, notes, and snippets.

@gyugyu90
Last active October 12, 2024 08:06
Show Gist options
  • Save gyugyu90/d64f932044eba50675f67766ef38b463 to your computer and use it in GitHub Desktop.
Save gyugyu90/d64f932044eba50675f67766ef38b463 to your computer and use it in GitHub Desktop.
class Coffee {
String beanType;
int waterAmount;
bool hot;
Syrup? syrup;
Coffee(this.beanType,
[this.waterAmount = 40, this.hot = true, this.syrup]);
// named constructor
Coffee.iceAmericano(this.beanType, this.waterAmount, [this.syrup])
: hot = false; // initializer list
bool isEspresso() {
return waterAmount <= 50;
}
}
void main() {
var coffee = Coffee.iceAmericano('콜롬비아 수프리모', 300);
print(coffee.hot); // false
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment