Aqliy qobilyatni aniqlaydigan mobil ilova yaratish


Download 196.34 Kb.
bet2/2
Sana05.04.2023
Hajmi196.34 Kb.
#1273586
1   2
Bog'liq
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:




Download 196.34 Kb.

Do'stlaringiz bilan baham:
1   2




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling