'Flutter: Instantiate object with multiple parameters

I've encountered a syntactical (i guess?) problem when trying to instantiate an object from my predefined constructor.

Category(String kategorieName, Image cover){
  kategorieTitel = kategorieName;
  kategorieCover = cover;
}

I tried to create a dynamic list which will later be used to auto-fill constructors in a ListView.builder.

  List kategorien = [
{
  'name' : 'Location1',
  'pic' : Asset.Image('assets/img/Locations.jpg')
},
{
  'name' : 'Location2',
   ...
}];

Auto-Filling the name works fine but I wasn't able to call the constructor with the according image-file.

  child: ListView.builder(
    itemCount: kategorien.length,
    itemBuilder: (context, index){
      return Padding(
        padding: EdgeInsets.all(5.0),
        child: Category('${kategorien[index]['name']}'),

I've tried concatenation like Category('${kategorien[index]['name']}', '${kategorien[index][pic]}')

I have no idea how to give the constructor the image by the list. I'd be very thankful for help!



Sources

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

Source: Stack Overflow

Solution Source