【问题标题】:The expression doesn't evaluate to function, so it can't be invoked?该表达式不计算为函数,所以它不能被调用?
【发布时间】:2020-10-27 19:08:45
【问题描述】:
class ShoppingListState extends State<ShoppingList> {
  @override
  Widget build(BuildContext context) {
    final List<String> shoppingItems = new List();
    shoppingItems.add("pain");
    shoppingItems.add("tomate");
    return ListView.builder(
        padding: const EdgeInsets.all(16.0),
        itemCount: shoppingItems.length,
        itemBuilder: (context,i) {
          return Text(shoppingItems(i));
        }
    );
  }
}
  

错误在return Text(shoppingItems());

【问题讨论】:

    标签: flutter dart


    【解决方案1】:

    shoppingItems 不是函数而是List,您可能希望访问位于i 位置的元素,以便使用shoppingItems[i] 替换您的代码。

    【讨论】:

    • 如果确实解决了您的问题,请将答案标记为已接受
    猜你喜欢
    • 2020-12-19
    • 1970-01-01
    • 2021-05-18
    • 2022-01-25
    • 2022-01-12
    • 1970-01-01
    • 2022-11-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多