google / built_collection.dart

Immutable Dart collections via the builder pattern.
https://pub.dev/packages/built_collection
BSD 3-Clause "New" or "Revised" License
275 stars 52 forks source link

asList() always returns a new instance #278

Open reneky opened 1 year ago

reneky commented 1 year ago

It would be nice if it created the immutable List on the first call, so that it can be used for Angular Dart @Input

davidmorgan commented 1 year ago

Thanks for the suggestion.

Does it not work to use the BuiltList directly? It is Iterable, after all.

We wouldn't want to add a field to BuiltList just for this as it would be trading memory in every case to support an occasional use case. An alternative implementation would be to use an "expando".