提问人:Saransh Sharma 提问时间:10/14/2023 最后编辑:Md. Yeasin SheikhSaransh Sharma 更新时间:10/14/2023 访问量:36
我使用 flutter 制作了一个基本的测验应用程序,在结果屏幕中显示正确答案和用户答案,但颜色和字体没有
I made a basic quiz app using flutter and in the result screen where the correct answers and user answers are displayed but the color and font isn't
问:
我使用 flutter 制作了一个基本的测验应用程序,在结果屏幕中显示正确答案和用户答案,但颜色和字体没有按预期显示,就像设置答案样式的代码不起作用一样。
在这里,我提供了完整的代码,有人可以告诉我为什么这不起作用。
import 'package:adv_basics/question_identifier.dart';
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
class SummaryItem extends StatelessWidget {
const SummaryItem(this.itemData, {super.key});
final Map<String, Object> itemData;
@override
Widget build(BuildContext context) {
final isCorrectAnswer =
itemData['user_answer'] == itemData['correct_answer'];
return Padding(
padding: const EdgeInsets.symmetric(
vertical: 8,
),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
QuestionIdentifier(
isCorrectAnswer: isCorrectAnswer,
questionIndex: itemData['question'] as int,
),
const SizedBox(width: 20),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
itemData['question'] as String,
style: GoogleFont.lato(
color: Color.white,
fontSize: 16,
fontWeight: FontWeight.bold,
),
),
const SizedBox(
height: 5,
),
Text(
itemData['user_answer'] as String,
style: const TextStyle(
color: Color.fromARGB(255, 202, 171, 252),
),
),
Text(
itemData['correct_answer'] as String,
style: const TextStyle(
color: Color.fromARGB(255, 181, 254, 246),
),
),
],
),
),
],
),
);
}
}
答:
0赞
Hamou Ouyaba
10/14/2023
#1
问题在这里:
您的代码 :
GoogleFont.lato(
color: Color.white,
fontSize: 16,
fontWeight: FontWeight.bold,
),
更正:
GoogleFonts.lato(
color: Colors.white,
fontSize: 16,
fontWeight: FontWeight.bold,
),
您只需要将“s”添加到 和 中。GoogleFonts.lato
Colors
评论
GoogleFonts
Colors
Text( itemData['question'] as String, style: GoogleFonts.lato( color: Colors.white, fontSize: 16, fontWeight: FontWeight.bold, ),