Skip to content

Commit

Permalink
fix: call super.dispose after disposing local resources
Browse files Browse the repository at this point in the history
  • Loading branch information
demchenkoalex committed Dec 30, 2024
1 parent 2cd362c commit f811437
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion examples/flyer_chat/lib/gemini.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ class GeminiState extends State<Gemini> {

@override
void dispose() {
super.dispose();
_chatController.dispose();
_scrollController.dispose();
_crossCache.dispose();
super.dispose();
}

@override
Expand Down
2 changes: 1 addition & 1 deletion examples/flyer_chat/lib/local.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ class LocalState extends State<Local> {

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

@override
Expand Down
2 changes: 1 addition & 1 deletion examples/flyer_chat/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ class _FlyerChatHomePageState extends State<FlyerChatHomePage> {

@override
void dispose() {
super.dispose();
_dio.close(force: true);
super.dispose();
}

@override
Expand Down
8 changes: 4 additions & 4 deletions packages/flutter_chat_ui/lib/src/chat.dart
Original file line number Diff line number Diff line change
Expand Up @@ -81,17 +81,17 @@ class _ChatState extends State<Chat> with WidgetsBindingObserver {

@override
void dispose() {
super.dispose();
WidgetsBinding.instance.removeObserver(this);
// Only try to dispose cross cache if it's not provided, since
// users might want to keep downloading media even after the chat
// is disposed.
if (widget.crossCache == null) {
_crossCache.dispose();
}
if (widget.scrollController == null) {
_scrollController.dispose();
}
if (widget.crossCache == null) {
_crossCache.dispose();
}
super.dispose();
}

@override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,10 @@ class ChatAnimatedListState extends State<ChatAnimatedList>

@override
void dispose() {
super.dispose();
_scrollToBottomShowTimer?.cancel();
_scrollToBottomController.dispose();
_operationsSubscription.cancel();
super.dispose();
}

@override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ class ChatAnimatedListReversedState extends State<ChatAnimatedListReversed> {

@override
void dispose() {
super.dispose();
_operationsSubscription.cancel();
super.dispose();
}

@override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ class ChatMessageInternalState extends State<ChatMessageInternal> {

@override
void dispose() {
super.dispose();
_operationsSubscription?.cancel();
super.dispose();
}

@override
Expand Down

0 comments on commit f811437

Please sign in to comment.