Skip to content

Commit

Permalink
fix: 🐛 correct usage of provide after unmount
Browse files Browse the repository at this point in the history
  • Loading branch information
jonasbadstuebner committed Jun 18, 2024
1 parent 232214c commit 7d1f066
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
to hide user name in chat.
* **Fix**: [182](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/issues/182) Fix
send message not working when user start texting after newLine.
* **Fix**: [191](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/pull/191) Fix
error when using `BuildContext` or `State` extensions when not mounted.

## [1.3.1]

Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
4. Make sure your code lints.
5. Push your work back up to your fork.
6. Create the pull request!
7. Include the PR in the CHANGELOG.md
10 changes: 6 additions & 4 deletions lib/src/extensions/extensions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -129,16 +129,18 @@ extension ChatViewStateTitleExtension on String? {

/// Extension on State for accessing inherited widget.
extension StatefulWidgetExtension on State {
ChatViewInheritedWidget? get provide => ChatViewInheritedWidget.of(context);
ChatViewInheritedWidget? get provide =>
mounted ? ChatViewInheritedWidget.of(context) : null;

ReplySuggestionsConfig? get suggestionsConfig =>
SuggestionsConfigIW.of(context)?.suggestionsConfig;
mounted ? SuggestionsConfigIW.of(context)?.suggestionsConfig : null;
}

/// Extension on State for accessing inherited widget.
extension BuildContextExtension on BuildContext {
ChatViewInheritedWidget? get provide => ChatViewInheritedWidget.of(this);
ChatViewInheritedWidget? get provide =>
mounted ? ChatViewInheritedWidget.of(this) : null;

ReplySuggestionsConfig? get suggestionsConfig =>
SuggestionsConfigIW.of(this)?.suggestionsConfig;
mounted ? SuggestionsConfigIW.of(this)?.suggestionsConfig : null;
}

0 comments on commit 7d1f066

Please sign in to comment.