我用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),
),
),
],
),
),
],
),
);
}
}
1条答案
按热度按时间ca1c2owp1#
问题就在这里:
验证码:
更正:
你只需要把“s”加到
GoogleFonts.lato
和Colors
上。