Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/flutter/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Dart 我试图在flifter中做一个选择题测验,但我在按钮和文本视图中分配字符串时遇到了麻烦_Dart_Flutter - Fatal编程技术网

Dart 我试图在flifter中做一个选择题测验,但我在按钮和文本视图中分配字符串时遇到了麻烦

Dart 我试图在flifter中做一个选择题测验,但我在按钮和文本视图中分配字符串时遇到了麻烦,dart,flutter,Dart,Flutter,正如您在列表答案[1]中看到的,我确实尝试在文本视图中指定字符串“白色”,但它使我的程序崩溃,任何人都知道为什么,我有课堂问题,其中包含一个字符串问题、一个带答案的列表和一个带正确答案的字符串进行评估,以及一个用于构建测验的测验类 Questions currentQuestion; Quiz quiz = new Quiz([ new Questions("Color of the snow is ", ["yellow", "white","grey"],'white']); Strin

正如您在
列表答案[1]
中看到的,我确实尝试在文本视图中指定字符串“白色”,但它使我的程序崩溃,任何人都知道为什么,我有课堂问题,其中包含一个字符串问题、一个带答案的列表和一个带正确答案的字符串进行评估,以及一个用于构建测验的测验类

Questions currentQuestion;

Quiz quiz = new Quiz([
new Questions("Color of the snow is ", ["yellow", "white","grey"],'white']);
 String questionText;
 int questionNumber;
 String isCorrect;
 List<String> listAnswers;

 @override
void initState() {
super.initState();
currentQuestion = quiz.nextQuestion;
questionText = currentQuestion.question;
questionNumber = quiz.questionNumber;
listAnswers = quiz.answers;
isCorrect = quiz.correctAnswer;
}

@override
Widget build(BuildContext context) {
return new Scaffold(
  appBar: new AppBar(
    title: new Text(widget.title),
  ),
  body: new InkWell(
    child: Center(
      child: new Column(
        children: <Widget>[
          Padding(
            padding: const EdgeInsets.all(8.0),
            child: new Text(
              questionText,
              maxLines: questionNumber,
              style: new TextStyle(fontSize: 20.0),
            ),
          ),
          Padding(
            padding: const EdgeInsets.all(8.0),
            child: new Text(
              listAnswers[1],
              style: new TextStyle(fontSize: 20.0),
            ),
          ),
        ],
      ),
    ),
   ),
  );
 }
}
问题-当前问题;
测验=新测验([
新问题(“雪的颜色是“,[“黄”、“白”、“灰”、“白”);
字符串文本;
整数;
字符串是正确的;
列出答案;
@凌驾
void initState(){
super.initState();
currentQuestion=quick.nextQuestion;
questionText=currentQuestion.question;
questionNumber=测验。questionNumber;
listAnswers=quick.answers;
isCorrect=测验。正确答案;
}
@凌驾
小部件构建(构建上下文){
归还新脚手架(
appBar:新的appBar(
标题:新文本(widget.title),
),
主体:新墨水池(
儿童:中心(
子:新列(
儿童:[
填充物(
填充:常数边集全部(8.0),
儿童:新文本(
问题文本,
maxLines:questionNumber,
样式:新文本样式(fontSize:20.0),
),
),
填充物(
填充:常数边集全部(8.0),
儿童:新文本(
列表答案[1],
样式:新文本样式(fontSize:20.0),
),
),
],
),
),
),
);
}
}

显示问题代码并询问您的崩溃日志非常确定您超出了范围。
NoSuchMethodError:方法“[]”是在null上调用的。Receiver:null尝试调用:[](1)
这是错误日志。现在我将发布代码,我不知道我在这里缺少了什么。