totalitarian
totalitarian

Reputation: 3666

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

Anyone know why I would get this error when trying to setup a getter for an UnmodifiableListView in provider?

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

Here is my code

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;

Upvotes: 0

Views: 141

Answers (1)

Reza M
Reza M

Reputation: 573

Please see this. Use this.

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

Upvotes: 1

Related Questions