I have this widget in Flutter/Dart:
Widget _buildTimeRow() {
var keys = widget.place!.openingTime.keys.toList();
var length = widget.showFull! ? keys.length : min(keys.length, 5);
return Container(
child: Column(
children: List.generate(
length,
(int index) => Container(
child: Row(
children: <Widget>[
Container(
width: 100,
child: Text(keys[index],
style: TextStyle(
fontWeight: FontWeight.w500)),
),
Expanded(
child: Container(
child: Text(widget.place!.openingTime[keys[index]] ?? "",
overflow: TextOverflow.ellipsis)),
),
],
),
))));
}
The problem is that I can not translate the Text(keys[index] part.
I tried adding this:
if (keys[index] == 1) ...[ // 1, 2, 3, 4, 5, 6 and so on.
Text(Localized.of(context)!.trans(LocalizedKey.NewWord) ?? "",
style: TextStyle(
fontWeight: FontWeight.bold,
),
),
],
This does not work. How could I get it to work so that I can translate the outcome of the list items (in the index) to be translated?
Is this even possible?