I am used to constructing an empty List and then adding items to it.
List<String> example = [];
The index of the list is automatically created and taken care of so that I never have to think about it, but also my knowledge of how to write for the list’s index is non-existent.
The problem is that another widget requires a reference to the list’s index value whereas I have no index variable when initialising this List.
So my question is, how could I rewrite my initialisation of the empty list ‘example’ so that it refers to the list’s built-in index value for subsequent use please?
With thanks.
2
Answers
I saw this after diving into the underlying Dart/Flutter code for a List item:
This might provide a way forward.
If I could write:
If I can write the above and it amounts to exactly the same thing as the empty list 'example' of this question, then that's the answer or an example of the answer that I'm seeking.
Pending the List’s object type, the answer can generally be written in the following format:
It is possible to write an extended initialisation of an empty list in Flutter/Dart.