Вы получаете ошибки, потому что:
1) Вы неправильно получаете доступ к элементам вашего List
. Для доступа к элементам в списке используйте метод elementAt
2) В свойстве children вашего Column
отсутствует оператор возврата.
3) Вместо использования счетчика для итерации через второй список. Вы можете сопоставить эти два списка с помощью IterableZip
.
Проверьте код ниже: он решает ошибки и отлично работает
int counter = 0;
class MyHomePage extends StatelessWidget {
static List<String> names = [
'name1',
'name2',
];
static List<String> difficulty = [
'easy',
'normal',
];
// access elements in a list using the elementAt function
String currentDifficulty = difficulty.elementAt(counter);
@override
Widget build(BuildContext context) {
names.map((e) => print(e));
return Scaffold(
body: Center(
child: Container(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
// map the two lists using IterableZip and passing the two lists
children: IterableZip([names, difficulty]).map(
(element) {
// missing return statement
return Container(
child: Column(
children: <Widget>[
// access elements of your first list here
Text(element[0]),
// access elements of your second list here
Text(element[1]),
],
),
);
},
).toList(),
),
),
),
);
}
}
OUTPUT

Надеюсь, это поможет.