I'm trying to turn a list of strings into a list of widgets, which are generated in a previous widget dynamically through a text edit / text edit controller.
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) {
I've then tried to create a list of widgets, but encounter issues with static members and initalisers.
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();