1

enter image description here

I'm new to flutter , or programming to be clear . I was following a course , doing the same as the Instructor , the app worked for him , but when i try to run it ,this error shows up .

Edit: tried to change Column to ListView but an error showed up .

 [![// @dart=2.9

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import './question.dart';
import './answer.dart';



class Quiz extends StatelessWidget {
  final List<Map<String, Object>> questions;
  final int questionIndex;
  final Function answerQuestion;

  Quiz(
      {@required this.questions,
      @required this.answerQuestion,
      @required this.questionIndex});

  @override
  Widget build(BuildContext context) {
    return ListView(
      children: \[
        Question(
          questions\[questionIndex\]\['questionText'\],
        ),
        ...(questions\[questionIndex\]\['answers'\] as List<Map<String, Object>>)
            .map((answer) {
          return Answer(() => answerQuestion(answer\['score'\]), answer\['text'\]);
        }).toList()
      \],
    );
  }
}][2]][2]
1
  • 1
    Add Column widget inside SingleChildScrollView() widget Jul 17, 2021 at 19:32

1 Answer 1

0

SingleChildScrollView( ) is for is for single child (and you have multiple)

Consider replacing your Column (children : [...]) with

ListView(

   children: [...]

);

rather than wrapping Column in SingleChildScrollView() this way you won't run into issues down the road πŸ™‚

4
  • replacing Column with ListView created another problem which is as following : ════════ Exception caught by widgets library ═══════════════════════════════════ The following assertion was thrown building Answer(dirty): A non-null String must be provided to a Text widget. 'package:flutter/src/widgets/text.dart': Failed assertion: line 378 pos 10: 'data != null' Jul 23, 2021 at 16:34
  • Could you edit your question with the full code leading to this error i’ll try to help you out - list view is really best to use here
    – Aristidios
    Jul 23, 2021 at 16:39
  • Your error has nothing to do with the list view... you'll see it still happens with Column & SingleChildScrollView - accept this answer & open an other one for this second issue - i'll see you there
    – Aristidios
    Jul 24, 2021 at 7:17
  • also clean up your code what are all the \\\\\\\\ about ?
    – Aristidios
    Jul 24, 2021 at 7:18

Your Answer

By clicking β€œPost Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.