Home > Back-end >  The named parameter 'key' is required, but there's no corresponding argument
The named parameter 'key' is required, but there's no corresponding argument

Time:12-15

i have problem in the panels of covid 19 data.to retrieve if someone have the code so please guide me.

countryData == null ? Container() : MostAffectedPanel( countryData: countryData ),

how i can solve this [1]: https://i.stack.imgur.com/e1eV8.png

CodePudding user response:

try countryData == null ? Container() : MostAffectedPanel(key:key, countryData: countryData ),

or make that key nullable in MostAffectedPanel constructor Eg: Key? key

CodePudding user response:

You need add key parameter

countryData == null ? 
Container() : MostAffectedPanel( key: UniqueKey(), countryData: countryData ),

CodePudding user response:

You need some changes in the constructor of your MostAffectedPanel class,

MostAffectedPanel({Key? key, required List<dynamic> countryData});

This is going to make the Key parameter nullable and your existing code will work just fine!

  • Related