Dennis Castro
Dennis Castro

Reputation: 45

Problems with bool on flutter

import 'package:flutter/material.dart';
import 'package:flutter_course/Questao.dart';
import 'package:flutter_course/Resposta.dart';

class Questionario extends StatelessWidget {
  final perguntas;
  final perguntaSelecionada;
  final responder;

  Questionario({
    @required this.perguntaSelecionada,
    @required this.perguntas,
    @required this.responder,
  })

 
  bool get temPerguntaSelecionada {
    return perguntaSelecionada < perguntas.length;
  }

  @override
  Widget build(BuildContext context) {

    var respostas = temPerguntaSelecionada
        ? perguntas[perguntaSelecionada]["responder"]
        : null;

    return Column(
      children: <Widget>[
        Questao(perguntas[perguntaSelecionada]["texto"]),
        ...respostas.map((t) => Resposta(t, responder)).tolist()
      ],
    );
  }
}

Guys, i'm having problems with variable bool, it's showing a red line saying that a function body must be provided. They're saying for me to try to add a function body, and i don't know how to add a function body inside of a class, can you guys help me please?

Upvotes: 0

Views: 202

Answers (1)

Abdallah Nassar
Abdallah Nassar

Reputation: 81

Add a semicolon(;) at the end of your constructor.

Questionario({
    @required this.perguntaSelecionada,
    @required this.perguntas,
    @required this.responder,
  })

should be

Questionario({
    @required this.perguntaSelecionada,
    @required this.perguntas,
    @required this.responder,
  });

Upvotes: 2

Related Questions