Quantcast
Channel: 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 - Stack Overflow
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

$
0
0

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



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>