Skip to content

Commit 237e67c

Browse files
fix: 🐛 Fix list UI not updated when received data from stream
1 parent 9a90ced commit 237e67c

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

lib/src/controller/auto_animated_sliver_list_controller.dart

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import 'dart:async';
22

3+
import 'package:flutter/foundation.dart';
34
import 'package:flutter/material.dart';
45

56
import '../extensions/extensions.dart';
@@ -315,7 +316,14 @@ class AutoAnimateSliverListController<T> {
315316
}
316317

317318
/// Do not use this method directly
318-
void updateItems(List<T> updatedItems) => _items = updatedItems;
319+
void updateItems(List<T> updatedItems) {
320+
_items = updatedItems;
321+
// Added ticket provider null check to avoid unnecessary updates
322+
// during animations or when calling updateItemsWithAnimation
323+
if (_tickerProvider == null && !listEquals(_items, _currentItems)) {
324+
_currentItems = List.from(_items);
325+
}
326+
}
319327

320328
/// Do not use this method directly
321329
void updateItemsWithAnimation({

0 commit comments

Comments
 (0)