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.
API docsによると、 Uint8Listは固定リストです。次のようなコードを使用できます。
var allInput = new Uint8List(1);
allInput[0] = 123;
拡張可能なリストが必要な場合は、次のようにすることができます。
var allInput = new List();
allInput.addAll(list);
また
var allInput = new List<int>();
allInput.addAll(list);
基本的に、リストを作成するときにサイズ指定子を指定すると、リストは固定サイズになります。それ以外の場合は拡張可能です ( ref )
Chris が答えに書いていることは今日は正しいですが、長さの引数が指定された場合、すぐにジェネリック List コンストラクターは固定長ではなくなります。リストのサイズは後で変更できます。の追加の名前付きコンストラクターもいくつかありますList
。
factory List.fixedLength(int length, {E fill: null})
factory List.filled(int length, E fill)
これらは、固定長のリストを構築し、値が事前に入力されたリストを作成するのに役立ちます。
へのブリーディング エッジの変更の詳細についてはList
、次を参照してください。
http://api.dartlang.org/docs/bleeding_edge/dart_core/List.html