Quantcast
Viewing all articles
Browse latest Browse all 2

Answer by Francisco Javier Snchez for This class (or a class which this class inherits from) is marked as '@imutable' but one or more of its instance fields are not final

You have to mark both list to final. You can still add and remove elements from your lists but you cannot re-initialize them.

You can

list.add('c')

You can't

list = ['apple']

In your case the correct code would look like this:

class Test extends StatelessWidget {  Final List<String> list = ['a', 'b'];  Final List<int> _ids = [];

Viewing all articles
Browse latest Browse all 2

Trending Articles