Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Non-nullable instance field 'questionText' must be initialized. Try adding an initializer expression, or add a field initializer in this constructor, or mark it 'late'. #27

Open
fobf opened this issue Sep 9, 2021 · 2 comments

Comments

@fobf
Copy link

fobf commented Sep 9, 2021

I have this error in the question. dart file. How can I correct it?

@fobf
Copy link
Author

fobf commented Sep 9, 2021

`class Question {
late String questionText;
late bool questionAnswer;

Question({required String q, required bool a}) {
questionText = q;
questionAnswer = a;
}
}
`
one of the possoble solution

@tlaw22
Copy link

tlaw22 commented May 2, 2023

class Question {
final String questionText;
final bool questionAnswer;

Question({
required this.questionText,
required this.questionAnswer,
});
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants