Aqliy qobilyatni aniqlaydigan mobil ilova yaratish



Yüklə 87,17 Kb.
səhifə2/2
tarix06.04.2023
ölçüsü87,17 Kb.
#93897
1   2
AZIZBEK-3MM

Question.dart file kodi:
import 'package:flutter/material.dart';
import "package:hexcolor/hexcolor.dart";

@immutable


class Question extends StatelessWidget {
final String textQuestion;

const Question(this.textQuestion, {Key? key}) : super(key: key);


@override


Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.only(bottom: 32),
child: SizedBox(
width: 360,
child: Text(textQuestion,
textAlign: TextAlign.center,
style: const TextStyle(
fontWeight: FontWeight.w700,
fontSize: 20,
color: Colors.black,
))));
}
}

Quiz.dart file kodi:
import 'package:flutter/material.dart';
import './question.dart';
import './answer.dart';

class Quiz extends StatelessWidget {


final List> data;
final int indexQuestion;
final Function answerQuestion;

const Quiz(


{required this.data,
required this.answerQuestion,
required this.indexQuestion,
Key? key})
: super(key: key);

@override


Widget build(BuildContext context) {
return Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Padding(
padding: const EdgeInsets.only(bottom: 32),
child: SizedBox(
width: 360,
child: Question(
data[indexQuestion]['questionText'] as String,
),
)),
...(data[indexQuestion]['answers'] as List>)
.map((answer) {
return Answer(
() => answerQuestion(answer['score']), answer['text'] as String);
}).toList(),
],
);
}
}

Result.dart file kodi:
import 'package:flutter/material.dart';
import './question.dart';
import 'package:hexcolor/hexcolor.dart';

class Result extends StatelessWidget {


final double resultScore;
final VoidCallback resetHandler;

const Result(this.resultScore, this.resetHandler, {Key? key})


: super(key: key);

String get resultPhrase {


String resultText;
final score = num.parse(resultScore.toStringAsFixed(2));

if (score <= 10.00) {


resultText =
'Xarakat qildingiz va natija $score ball ! \n Qayta urinishni xoxlaysizmi?';
} else if (score > 10.00 && score <= 25.00) {
resultText =
'Siz bajardingiz va natija $score ball ! \n Qayta urinishni xoxlaysizmi?';
} else if (score > 25.00 && score <= 40.00) {
resultText =
'Deyarli uddaladingiz natija $score ball ! \n Qayta urinishni xoxlaysizmi?';
} else {
resultText =
'Siz uddaladingiz natija $score ball ! \n Qayta urinishni xoxlaysizmi?';
}

return resultText;


}

@override


Widget build(BuildContext context) {
return Center(
child: Align(
alignment: Alignment.center,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Padding(
padding: const EdgeInsets.only(bottom: 32),
child: SizedBox(
width: 360,
child: Question(
resultPhrase,
),
)),
ElevatedButton(
child: SizedBox(
width: 200,
child: Text(
'Qayta urinish',
textAlign: TextAlign.center,
style: TextStyle(
fontWeight: FontWeight.w400,
color: HexColor("#FEFEFE"),
),
),
),
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all(Colors.green)),
onPressed: resetHandler,
)
],
)));
}
}

Natijaviy ko’rinish:




Yüklə 87,17 Kb.

Dostları ilə paylaş:
1   2




Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©azkurs.org 2024
rəhbərliyinə müraciət

gir | qeydiyyatdan keç
    Ana səhifə


yükləyin