londonappbrewery / quizzler-flutter

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

The named parameter 'ans' is required, but there's no corresponding argument. Try adding the required argument.dartmissing_required_argument #30

Closed Aayush-310 closed 1 year ago

Aayush-310 commented 2 years ago

//questio_n.dart class Question { late String questionText; late bool questionAns; Question({required String qN, required bool ans}) { questionText = qN; questionAns = ans; } } //quiz_brain.dart import 'package:quizzler/questio_n.dart';

import 'questio_n.dart';

class QuizBrain { List listofquestions = [ Question( 'hello',false) ]; } //why cant the class object be initialized without specifying qN='hello'

AkshaySiddannavar commented 2 years ago

It is most probably because you're using named parameters in Question({required String qN, required bool ans}) but you are passing values as if they were positional parameters in Question( 'hello',false)

Write Question( qN : 'hello', ans : false) instead and try

Let me know if some problem comes up