3 ошибки в коде, не могу решить
Ошибки находятся в 74 строчке(2 ошибки ("'ResultScreen' isn't a function. Try correcting the name to match an existing function, or define a method or function named 'ResultScreen'." и "The name 'ResultScreen' is defined in the libraries 'package:app2/answer_widget.dart' and 'package:app2/result_screen.dart'. Try using 'as prefix' for one of the import directives, or hiding the name from all but one of the imports.")) и так же ошибка в 120 строчке
import 'question_widget.dart';
import 'answer_widget.dart';
import 'result_screen.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: QuizApp(),
);
}
}
class QuizApp extends StatefulWidget {
@override
_QuizAppState createState() => _QuizAppState();
}
class _QuizAppState extends State<QuizApp> {
int _currentQuestionIndex = 0;
int _correctAnswers = 0;
final List<Map<String, dynamic>> _questions = [
{
'question': 'В каком году произошла Великая Французская Революция?',
'answers': ['1789', '1776', '1811'],
'correctIndex': 0,
'backgroundImage': 'assets/background1.png',
},
{
'question': 'Кто написал произведение "Преступление и наказание"?',
'answers': ['Иван Тургенев', 'Лев Толстой', ' Федор Достоевский'],
'correctIndex': 2,
'backgroundImage': 'assets/background2.png',
},
{
'question': 'Какое химическое вещество обозначается символом "H2O"?',
'answers': ['Углекислый газ', 'Кислород', 'Вода'],
'correctIndex': 2,
'backgroundImage': 'assets/background3.png',
},
{
'question': 'В каком году состоялся первая мужская мировой футбольный чемпионат?',
'answers': ['1930', '1950', '1966'],
'correctIndex': 0,
'backgroundImage': 'assets/background4.png',
},
{
'question': 'Кто является автором произведения "Ромео и Джульетта"?',
'answers': ['Чехов', 'Шекспир', 'Достоевский'],
'correctIndex': 1,
'backgroundImage': 'assets/background5.png',
},
];
void _answerQuestion(int selectedIndex) {
if (_currentQuestionIndex < _questions.length) {
setState(() {
if (_questions[_currentQuestionIndex]['correctIndex'] == selectedIndex) {
_correctAnswers++;
}
_currentQuestionIndex++;
if (_currentQuestionIndex >= _questions.length) {
// Показать итоговое количество правильных ответов
// Перейти на экран с результатами
_currentQuestionIndex--;
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => ResultScreen(
correctAnswers: _correctAnswers,
totalQuestions: _questions.length,
),
),
);
}
});
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Викторина'),
flexibleSpace: Container(
decoration: const BoxDecoration(
gradient: LinearGradient(
colors: [Color.fromARGB(255, 174, 82, 197), Color.fromARGB(255, 194, 192, 72)],
begin: Alignment.topLeft,
end: Alignment.bottomRight,
stops: [0.0, 1.0],
tileMode: TileMode.clamp,
),
),
),
),
body: Container(
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage(
_questions[_currentQuestionIndex]['backgroundImage'],
),
fit: BoxFit.cover,
),
),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
QuestionWidget(_questions[_currentQuestionIndex]['question']),
...(_questions[_currentQuestionIndex]['answers'] as List<String>)
.map((answer) {
return AnswerWidget(() => _answerQuestion(
_questions[_currentQuestionIndex]['answers'].indexOf(answer)),
answer);
}).toList(),
],
),
),
);
}
}```