79286078

Date: 2024-12-16 21:11:35
Score: 0.5
Natty:
Report link

After I searched lots of questions in stackoverflow I get the solution. I changed these parts of code:

ElevatedButton.styleFrom(
                                    backgroundColor: result ==
                                                AppLocalizations.of(context)
                                                    ?.truth_answer &&
                                            selectedOption == option
                                        ? Colors.red
                                        : result ==
                                                    AppLocalizations.of(context)
                                                        ?.wrong_answer &&
                                                selectedOption == option
                                            ? Colors.blue
                                            : result ==
                                                        AppLocalizations.of(context)
                                                            ?.wrong_answer &&
                                                    currentQuestion["answer"]
                                                            as String ==
                                                        option
                                                ? Colors.red
                                                : Colors.blue),

with these code:

ButtonStyle(
                              backgroundColor: WidgetStateProperty.resolveWith<Color>((states) {
                                if (result == AppLocalizations.of(context)?.truth_answer && selectedOption == option) {
                                  return Colors.green;
                                } else if (result == AppLocalizations.of(context)?.wrong_answer && selectedOption == option) {
                                  return Colors.blue;
                                } else if (result == AppLocalizations.of(context)?.wrong_answer && currentQuestion["answer"] as String == option) {
                                  return Colors.green;
                                } else {
                                  return Colors.blue.shade200;
                                }
                              }),
                            ),
Reasons:
  • Blacklisted phrase (1): stackoverflow
  • Long answer (-1):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: Ahmet Yılmaz