Skip to content

Commit 2f1b7dd

Browse files
fix: 🐛 correct usage of provide after unmount
1 parent 232214c commit 2f1b7dd

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

lib/src/extensions/extensions.dart

+6-4
Original file line numberDiff line numberDiff line change
@@ -129,16 +129,18 @@ extension ChatViewStateTitleExtension on String? {
129129

130130
/// Extension on State for accessing inherited widget.
131131
extension StatefulWidgetExtension on State {
132-
ChatViewInheritedWidget? get provide => ChatViewInheritedWidget.of(context);
132+
ChatViewInheritedWidget? get provide =>
133+
mounted ? ChatViewInheritedWidget.of(context) : null;
133134

134135
ReplySuggestionsConfig? get suggestionsConfig =>
135-
SuggestionsConfigIW.of(context)?.suggestionsConfig;
136+
mounted ? SuggestionsConfigIW.of(context)?.suggestionsConfig : null;
136137
}
137138

138139
/// Extension on State for accessing inherited widget.
139140
extension BuildContextExtension on BuildContext {
140-
ChatViewInheritedWidget? get provide => ChatViewInheritedWidget.of(this);
141+
ChatViewInheritedWidget? get provide =>
142+
mounted ? ChatViewInheritedWidget.of(this) : null;
141143

142144
ReplySuggestionsConfig? get suggestionsConfig =>
143-
SuggestionsConfigIW.of(this)?.suggestionsConfig;
145+
mounted ? SuggestionsConfigIW.of(this)?.suggestionsConfig : null;
144146
}

0 commit comments

Comments
 (0)