代码之家  ›  专栏  ›  技术社区  ›  totalitarian

_TypeError(类型“List<String>”不是类型“UnmodifiableListView<String>”的子类型)

  •  0
  • totalitarian  · 技术社区  · 4 年前

    UnmodifiableListView 在提供者中?

    _TypeError (type 'List<String>' is not a subtype of type 'UnmodifiableListView<String>')
    

    这是我的密码

    List<String> _failures = [
        '>1.5 year',
        '3 months to 1.5 years',
        '2 weeks to 3 months',
        '2 days to 2 weeks',
        'Now',
      ];
    
    UnmodifiableListView<String> get failures => _failures;
    
    1 回复  |  直到 4 年前
        1
  •  1
  •   Reza M    4 年前

    请看 this . 用这个。

    UnmodifiableListView<String> get failures => UnmodifiableListView(_failures)