I cannot get the length of all my elements in my list because it contains Widgets. Is there a way I can get around this? I use following code to generate the list with the element lenghts.
I’m getting following error: The element type 'List<Container>' can't be assigned to the list type 'Widget'.dartlist_element_type_not_assignable.
This is an example of the contents list I’m trying to get the length from: Contents list
I’ve tried list builder instead of list generator but this doesn’t seem to make a difference.
>Solution :
Add spread operator at the front if the List, and use the length on the List normally.
children: [
...List.generate(contents.length, (index) => buildDot(index, context)), // add ... like this in your List
],
this will lead that your list will be merged with the principal list.