jeudi 10 septembre 2020

How to configure Text value in flutter based on conditions?

I fetching the below single character code from the server like 'M', 'T' or 'B', etc in flutter application

M = Manual
T = Trial
B = Baking
N = N/A
S = Source
O = Other Source

Now there is only Text() element configured in a listview which has to represent the value like 'Manual','Trial'or 'Baking' etc, based on the code retrieved.

I know how to implement the ternary operator , if there was only 2 elements to be choosen from. But in this case there are 6 options and only one was to be represented.

How should I configure this in flutter listview builder??

 child:Text('value to be represented here')

I am not able to understand how the 'if-else if - else' will work here?

Aucun commentaire:

Enregistrer un commentaire