londonappbrewery / quizzler-flutter

Learn to Code While Building Apps - The Complete Flutter Development Bootcamp
https://www.appbrewery.co
196 stars 870 forks source link

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 2 years ago

fobf commented 2 years ago

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

fobf commented 2 years ago

`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 commented 1 year ago

class Question { final String questionText; final bool questionAnswer;

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