I have a listview which is using flutter_riverpod. The listview have 2 variable. First variable is word text and second variable is length of index.
ListView.builder(
itemCount: ref.watch(itemsProvider).length,
itemBuilder: (BuildContext context, int index) {
return Row(
children: [
Text(ref.watch(itemsProvider)[index]),
Text(ref.watch(itemsProvider)[index].length),
],
);
},
),
I am using this listview.builder. the first text of Row is working but second text of Row is not working. The error:
the argument type 'int ' can't be assigned to the parameter type 'string'
How can I solve this problem. The is no problem in widget. I am using consumerwidget, ref and widgetref. and scopped runapp Thanks for help.
CodePudding user response:
Text
widget seeks from String
, Use string format
Text("${ref.watch(itemsProvider)[index].length}"),
Also, you can use .toString()
More about dart-core