I want to create a buffer that can appended things.
For example
var allInput = new Uint8List(1);
allInput.add(list)
But it's informed me that this is can not be modify.
I want to create a buffer that can appended things.
For example
var allInput = new Uint8List(1);
allInput.add(list)
But it's informed me that this is can not be modify.
Per the API docs, Uint8List is a fixed list. You could use code such as:
var allInput = new Uint8List(1);
allInput[0] = 123;
If you want a growable list, you could do something like:
var allInput = new List();
allInput.addAll(list);
or
var allInput = new List<int>();
allInput.addAll(list);
Essentially, if you provide a size specifier when creating a list, that makes it fixed size. Otherwise it's extendable (ref)
What Chris writes in his answer is correct today, but starting soon, the generic List constructor will not be fixed length when a length argument is given. The list’s size will still be changeable afterwards. There will also be a couple of additional named constructors for List:
factory List.fixedLength(int length, {E fill: null})
factory List.filled(int length, E fill)
these will help with constructing fixed length lists and creating lists with pre-filled values.
For details on bleeding edge changes to List, see:
http://api.dartlang.org/docs/bleeding_edge/dart_core/List.html