Debug School

rakesh kumar
rakesh kumar

Posted on

HOW TO CHANGE TEXT COLOR BASED ON USER ID IN FLUTTER?-FLUTTER

Output Screenshot:

SOLUTION

Text(name,
     style: TextStyle(
            ccccccccccccccccccc: (user_id == 1)? Colors.red : (user_id) == 2 ?Colors.blue : Colors.black, 
            fontWeight: FontWeight.bold
       ),),
Enter fullscreen mode Exit fullscreen mode
 var backgroundColor = Colors.red;



    FutureBuilder(
    future: http.get('http://google.com')
    builder:(context,snapshot){
    backgroundColor =  snapshot.data[index].color

    return AwesomeData(snapshot.data)
    }
    ),

Enter fullscreen mode Exit fullscreen mode

Full Summary:
inside TextStyle in color,apply ternary operato
Refrence
Click here

Top comments (0)