I am looping through an array i.e 'companies' using the for loop. I want to display the first element in this array using 'for loop' without having to do it this way 'companies[0].name'. Here is what I have done which works but I need to use them for loop.
child: Column(
children: < Widget > [
// for (var item in companies)
companies.length > 0 ?
Text(
'${companies[0].name}'.toUpperCase(), // how can i replace this using the for loop
style: TextStyle(
color: AppColor.white,
),
) :
Text('No Company Assigned '),
],
),
companies.length > 0 ? ...companies.map((c) => Text('${c.name}')) : Text('No Company Assigned ')companies[0].nameand why do you need to usefor loop, can you clarify your question?Columnfor if it has just one child? what actually do you want to achieve?