'The named parameter 'key' is required, but there's no corresponding argument. MyHomePage and EditableLIstTitle

I have been struggling with a The named parameter 'key' is required but there's no corresponding argument. I have been running my code on android studio using flutter. The code was flagged with both of my MyHomepage and EditableListTile classes. The problem terminal suggested that I add a key: null at the end of the parenthesis, it did not work. Am I missing something or need to add to my classes.

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Edit Test',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(title: 'Edit Test'),
    );
  }
}
class MyHomePage extends StatefulWidget {
  MyHomePage({required Key key, required this.title}) : super(key: key);

  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}
Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: Text(widget.title),
        ),
        body: ListView.builder(
          itemCount: list.length,
          itemBuilder: (context, index) => EditableListTile(
            model: list[index],
            onChanged: (ListModel updatedModel) {
              list[index] = updatedModel;
            },
          ),
        ));
  }
}
class EditableListTile extends StatefulWidget {
  final ListModel model;
  final Function(ListModel listModel) onChanged;
  const EditableListTile({required Key key, required this.model, required this.onChanged})
      : super(key: key);

  @override
  _EditableListTileState createState() => _EditableListTileState();
} ```



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source