Skip to content

Instantly share code, notes, and snippets.

@gyugyu90
Last active October 12, 2024 06:17
Show Gist options
  • Save gyugyu90/184686b8a0542a1230a8616c02bc5f38 to your computer and use it in GitHub Desktop.
Save gyugyu90/184686b8a0542a1230a8616c02bc5f38 to your computer and use it in GitHub Desktop.
class Tea {
final String teaBag;
Milk? milk;
late String allergyInfo;
Tea(this.teaBag, [this.milk]);
}
class Milk {
String name = "서울우유";
int amount = 100;
}
String fetchAllergyInfo(Tea tea) {
// search allergy information...
const result = api.fetchAllergyInfo(tea);
return result;
}
void main() {
var tea = Tea('얼그레이');
tea.milk = Milk();
// print(tea.allergyInfo); // LateInitializationError: Field 'allergyInfo' has not been initialized.
tea.allergyInfo = fetchAllergyInfo(tea);
print(tea.allergyInfo);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment