Skip to content

Commit 3ae958e

Browse files
committed
compose [nfc]: Put _controller?.dispose inside _setNewController
1 parent 1619b0c commit 3ae958e

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

lib/widgets/compose_box.dart

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1989,7 +1989,6 @@ class _ComposeBoxState extends State<ComposeBox> with PerAccountStoreAwareStateM
19891989
final store = PerAccountStoreWidget.of(context);
19901990
final outboxMessage = store.takeOutboxMessage(localMessageId);
19911991
setState(() {
1992-
this.controller.dispose();
19931992
_setNewController(store);
19941993
final controller = this.controller;
19951994
controller
@@ -2092,7 +2091,6 @@ class _ComposeBoxState extends State<ComposeBox> with PerAccountStoreAwareStateM
20922091
// Fetch-raw-content failed; abort the edit session.
20932092
// An error dialog was already shown, by fetchRawContentWithFeedback.
20942093
setState(() {
2095-
controller.dispose();
20962094
_setNewController(PerAccountStoreWidget.of(context));
20972095
});
20982096
return;
@@ -2120,7 +2118,6 @@ class _ComposeBoxState extends State<ComposeBox> with PerAccountStoreAwareStateM
21202118

21212119
final store = PerAccountStoreWidget.of(context);
21222120
setState(() {
2123-
controller.dispose();
21242121
_setNewController(store);
21252122
});
21262123
}
@@ -2145,6 +2142,7 @@ class _ComposeBoxState extends State<ComposeBox> with PerAccountStoreAwareStateM
21452142
}
21462143

21472144
void _setNewController(PerAccountStore store) {
2145+
_controller?.dispose(); // `?.` because this might be the first call
21482146
switch (widget.narrow) {
21492147
case ChannelNarrow():
21502148
_controller = StreamComposeBoxController(store: store);

0 commit comments

Comments
 (0)