Last active
October 12, 2024 06:17
-
-
Save gyugyu90/184686b8a0542a1230a8616c02bc5f38 to your computer and use it in GitHub Desktop.
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
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