【问题标题】:type 'List<Widget>' is not a subtype 'List<Map<String,Object>>' of function... flutter类型“List<Widget>”不是函数的子类型“List<Map<String,Object>>”...颤动
【发布时间】:2021-09-05 19:05:30
【问题描述】:

我有变量

  final List<Map<String, Object>> _pages = [
    {'page': Page1(), 'title': 'Page1'},
    {'page': Page2(), 'title': 'Page2'}
  ];

然后在appBar标题中我要使用这个变量

 title: Text(_pages[1]['title']),

但我得到错误

type 'List' 不是 type 的子类型 '列表>'....

我尝试使用动态而不是对象,但没有帮助。 有什么办法吗?

【问题讨论】:

    标签: string flutter dictionary object widget


    【解决方案1】:

    这样做:

     title: Text(((_pages[1])['title']).toString()),
    

    【讨论】:

    • VScode 抛出错误 > 参数类型“对象?”不能分配给参数类型'String'
    猜你喜欢
    • 1970-01-01
    • 2021-01-10
    • 1970-01-01
    • 1970-01-01
    • 2020-01-18
    • 2021-01-10
    • 2021-12-29
    • 2023-01-08
    • 2020-02-01
    相关资源
    最近更新 更多