@@ -154,15 +154,17 @@ class ParseLiveList<T extends ParseObject> {
154154
155155 // Log lazy loading mode only once during initialization to avoid log spam
156156 if (_debugLoggedInit) {
157- print ('ParseLiveList: Initialized with lazyLoading=${_lazyLoading ? 'on' : 'off' }, preloadedColumns=${_preloadedColumns .isEmpty ? 'none' : _preloadedColumns .join (", " )}' );
157+ print (
158+ 'ParseLiveList: Initialized with lazyLoading=${_lazyLoading ? 'on' : 'off' }, preloadedColumns=${_preloadedColumns .isEmpty ? 'none' : _preloadedColumns .join (", " )}' ,
159+ );
158160 _debugLoggedInit = false ;
159161 }
160162
161163 // Only restrict fields if lazy loading is enabled AND preloaded columns are specified
162164 // This allows fetching minimal data upfront and loading full objects on-demand
163165 if (_lazyLoading && _preloadedColumns.isNotEmpty) {
164166 final List <String > keys = _preloadedColumns.toList ();
165-
167+
166168 // Automatically include order fields to ensure sorting works correctly
167169 if (query.limiters.containsKey ('order' )) {
168170 keys.addAll (
@@ -174,7 +176,7 @@ class ParseLiveList<T extends ParseObject> {
174176 }),
175177 );
176178 }
177-
179+
178180 query.keysToReturn (keys);
179181 }
180182
@@ -538,7 +540,7 @@ class ParseLiveList<T extends ParseObject> {
538540 final element = _list[index];
539541
540542 // If not yet loaded (happens with lazy loading), trigger loading
541- // This will only happen once per element due to the loaded flag
543+ // This will only happen once per element due to the loaded and _isLoading flags
542544 if (! element.loaded) {
543545 _loadElementAt (index);
544546 }
@@ -601,7 +603,8 @@ class ParseLiveList<T extends ParseObject> {
601603 _list[index].object = response.results! .first;
602604 } else if (response.error != null ) {
603605 // Emit error to the element's stream so listeners can handle it
604- element.emitError (response.error! , StackTrace .current);
606+ // Use _list[index] to ensure we emit to the current element at this index
607+ _list[index].emitError (response.error! , StackTrace .current);
605608 if (_debug) {
606609 print (
607610 'ParseLiveList: Error loading element at index $index : ${response .error }' ,
@@ -610,14 +613,13 @@ class ParseLiveList<T extends ParseObject> {
610613 } else {
611614 // Object not found (possibly deleted between initial query and load)
612615 if (_debug) {
613- print (
614- 'ParseLiveList: Element at index $index not found during load' ,
615- );
616+ print ('ParseLiveList: Element at index $index not found during load' );
616617 }
617618 }
618619 } catch (e, stackTrace) {
619620 // Emit exception to the element's stream
620- element.emitError (e, stackTrace);
621+ // Use _list[index] to ensure we emit to the current element at this index
622+ _list[index].emitError (e, stackTrace);
621623 if (_debug) {
622624 print (
623625 'ParseLiveList: Exception loading element at index $index : $e \n $stackTrace ' ,
0 commit comments