Skip to content

Commit

Permalink
fix: 🐛 correct removal of newSuggestions listener
Browse files Browse the repository at this point in the history
  • Loading branch information
jonasbadstuebner committed Jun 17, 2024
1 parent 232214c commit dcc3ad9
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/src/widgets/suggestions/suggestion_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class _SuggestionListState extends State<SuggestionList>
with SingleTickerProviderStateMixin {
late AnimationController _controller;

ValueNotifier<List<SuggestionItemData>>? newSuggestions;
@override
void initState() {
super.initState();
Expand All @@ -32,15 +33,15 @@ class _SuggestionListState extends State<SuggestionList>
);
WidgetsBinding.instance.addPostFrameCallback((_) {
if (!mounted) return;
final newSuggestions = provide?.chatController.newSuggestions;
newSuggestions = provide?.chatController.newSuggestions;
newSuggestions?.addListener(animateSuggestionList);
});
}

void animateSuggestionList() {
final newSuggestions = provide?.chatController.newSuggestions;
newSuggestions = provide?.chatController.newSuggestions;
if (newSuggestions != null) {
newSuggestions.value.isEmpty
newSuggestions!.value.isEmpty
? _controller.reverse()
: _controller.forward();
}
Expand Down Expand Up @@ -93,7 +94,6 @@ class _SuggestionListState extends State<SuggestionList>
@override
void dispose() {
_controller.dispose();
final newSuggestions = provide?.chatController.newSuggestions;
newSuggestions?.removeListener(animateSuggestionList);
super.dispose();
}
Expand Down

0 comments on commit dcc3ad9

Please sign in to comment.