Add mounted check to prevent updates on unmounted widgets
This commit is contained in:
parent
5494019be5
commit
35434b09d1
1 changed files with 3 additions and 0 deletions
|
|
@ -194,6 +194,8 @@ class MessageToolbarState extends State<MessageToolbar> {
|
|||
late StreamSubscription<MessageMode> toolbarModeStream;
|
||||
|
||||
void updateMode(MessageMode newMode) {
|
||||
//Early exit from the function if the widget has been unmounted to prevent updates on an inactive widget.
|
||||
if (!mounted) return;
|
||||
if (updatingMode) return;
|
||||
debugPrint("updating toolbar mode");
|
||||
final bool subscribed =
|
||||
|
|
@ -347,6 +349,7 @@ class MessageToolbarState extends State<MessageToolbar> {
|
|||
Timer? timer;
|
||||
selectionStream =
|
||||
widget.textSelection.selectionStream.stream.listen((value) {
|
||||
//talk about this
|
||||
timer?.cancel();
|
||||
timer = Timer(const Duration(milliseconds: 500), () {
|
||||
if (value != null && value.isNotEmpty) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue