From ef6fc1c9c8d69e27334ae2f3934610298f967405 Mon Sep 17 00:00:00 2001 From: Doug Borg Date: Sat, 7 Feb 2026 22:50:01 -0700 Subject: [PATCH] Materialize options iterable to list in optionsViewBuilder Avoids repeated iteration of the lazy .where().take() iterable on each call to .length and .elementAt() in ListView.builder. Co-Authored-By: Claude Opus 4.6 --- lib/widgets/nsi_tag_value_field.dart | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/widgets/nsi_tag_value_field.dart b/lib/widgets/nsi_tag_value_field.dart index 314c597..2919abd 100644 --- a/lib/widgets/nsi_tag_value_field.dart +++ b/lib/widgets/nsi_tag_value_field.dart @@ -143,6 +143,7 @@ class _NSITagValueFieldState extends State { AutocompleteOnSelected onSelected, Iterable options, ) { + final optionList = options.toList(growable: false); return Align( alignment: Alignment.topLeft, child: Material( @@ -153,9 +154,9 @@ class _NSITagValueFieldState extends State { child: ListView.builder( padding: EdgeInsets.zero, shrinkWrap: true, - itemCount: options.length, + itemCount: optionList.length, itemBuilder: (context, index) { - final option = options.elementAt(index); + final option = optionList[index]; return ListTile( dense: true, title: Text(option, style: const TextStyle(fontSize: 14)),