Flutter从字符串列表中创建小部件列表并出现错误

我正在尝试将字符串列表转换为小部件列表,这些小部件通过文本编辑/文本编辑控制器在先前的小部件中动态生成。

I've pulled the dynamic list names into a new stateful widget.

class NameMachine extends StatefulWidget {
  final List<String> names;

  NameMachine({Key key, @required this.names}) : super(key: key);

  @override
  State<StatefulWidget> createState() {
    return _NameMachineState(names);
  }
}

class _NameMachineState extends State<NameMachine> {
  final List<String> names;
 @override
  Widget build(BuildContext context) {

然后,我尝试创建小部件列表,但是遇到静态成员和初始化器问题。

final List<Widget> nameSlots = ...(names)
      .map(
        (names) => Container(
          padding: EdgeInsets.all(4.0),
          color: Colors.white,
          child: Text(
            names,
            textScaleFactor: 1.2,
            textAlign: TextAlign.center,
          ),
          width: double.infinity,
          height: double.infinity,
        ),
      )
      .toList();