Amir
Amir

Reputation: 65

How to define TextStyle depending on a boolean value in a flutter?

I'm getting a boolean status true or false from Api, to define whether it is active or inactive like shown bellow :

Align(
                                 alignment: Alignment.topLeft,
                                 child: Text(' ${sectorsProvider.sectorsList[index].is_active == false ?
                                   'Inactive' 
                                   :  'Active' 
                                 }',
                                  style: TextStyle(
                                    fontWeight: FontWeight.bold,
                                    fontSize: 20,
                                    color: sunnyColor),
                                    ),
                                    ),

I want to set a TextStyle for both active and inactive. thanks for help

Upvotes: 0

Views: 393

Answers (1)

Dabbel
Dabbel

Reputation: 2825

Text('bla',
  style: sectorsProvider.sectorsList[index].is_active== true
    ? TextStyle(...) 
    : TextStyle(...),
)

Upvotes: 1

Related Questions