'How to define conditional text color in Text widget Flutter
Solution 1:[1]
I think your issue is related to null safety if nDataList.temp allows null you can't do the check as you did, the solution could be
Text(
(nDataList.temp ?? 0) >= temp ? 'Normal' : 'Not Normal',
style: const TextStyle(
fontWeight: FontWeight.bold,
fontSize: 12,
color: (nDataList.temp ?? 0) >= temp ? Colors.white : Colors.red,
),
),
Solution 2:[2]
Try this in your commandline:
First, flutter clean
Then flutter run
Solution 3:[3]
thanks all, my problem in const before TextStyle() widget
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Shady Mohamed Sherif |
| Solution 2 | Eko Muhammad Rilo Pembudi |
| Solution 3 | KAnggara75 |

