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 18, 2024
1 parent e3e154a commit f08803b
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions lib/src/widgets/suggestions/suggestion_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,18 @@ class _SuggestionListState extends State<SuggestionList>
vsync: this,
);
WidgetsBinding.instance.addPostFrameCallback((_) {
if (!mounted) return;
final newSuggestions = provide?.chatController.newSuggestions;
newSuggestions?.addListener(animateSuggestionList);
});
}

@override
void activate() {
super.activate();
final newSuggestions = provide?.chatController.newSuggestions;
newSuggestions?.addListener(animateSuggestionList);
}

void animateSuggestionList() {
final newSuggestions = provide?.chatController.newSuggestions;
if (newSuggestions != null) {
Expand Down Expand Up @@ -91,10 +97,15 @@ class _SuggestionListState extends State<SuggestionList>
}

@override
void dispose() {
_controller.dispose();
void deactivate() {
final newSuggestions = provide?.chatController.newSuggestions;
newSuggestions?.removeListener(animateSuggestionList);
super.deactivate();
}

@override
void dispose() {
_controller.dispose();
super.dispose();
}
}

0 comments on commit f08803b

Please sign in to comment.