android 我用flutter做了一个基本的测验应用程序,在结果屏幕上显示了正确答案和用户答案,但没有显示颜色和字体

toe95027  于 12个月前  发布在  Android
关注(0)|答案(1)|浏览(94)

我用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),
                  ),
                ),
              ],
            ),
          ),
        ],
      ),
    );
  }
}

the final result screen for the app

ca1c2owp

ca1c2owp1#

问题就在这里:
验证码:

GoogleFont.lato(
                    color: Color.white,
                    fontSize: 16,
                    fontWeight: FontWeight.bold,
               ),

更正:

GoogleFonts.lato(
                    color: Colors.white,
                    fontSize: 16,
                    fontWeight: FontWeight.bold,
                  ),

你只需要把“s”加到GoogleFonts.latoColors上。

相关问题