Dynamically Change Text Color in ListView Based on API Response in FlutterFlow

Widgets & Design

I'm developing a FlutterFlow application that fetches data from an API. The data includes a list of time slots, each with a slot (time) and an available (boolean) property. I need to display these time slots in a ListView, with the text color changing based on the available property:

  • Green if available is true

  • Red if available is false

here is the json schema of my API
[

{

"image": "https://5.imimg.com/data5/SELLER/Default/2022/8/DG/TO/XK/122137434/futsal-artificial-grass-ground.jpeg",

"description": "A beautiful place to play football",

"turf_name": "City Arena",

"place_name": "Mangalore",

"google_map_embed": "https://g.co/kgs/9ySjgWW",

"number_of_grounds": 2,

"price_ground_1": 1000,

"players_per_team_ground_1": 5,

"price_ground_2": 1200,

"players_per_team_ground_2": 6,

"timeSlots": [

{

"slot": "09:00 AM",

"available": true

},

{

"slot": "10:00 AM",

"available": false

},

{

"slot": "11:00 AM",

"available": true

},

],

"id": 1,

"uuid": "960fee8a-1176-496f-b2c2-1e66f510f46f"

},
]

currently I am displaying the timeslots properly using the api but Now I want to change the color where if the available slot is true then I need to change the color to green and if false then it should change to red.

What have you tried so far?

did some of the things and still could not find the solution

Did you check FlutterFlow's Documentation for this topic?
Yes
3
9 replies