File tree Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -125,6 +125,8 @@ class CodeController extends TextEditingController {
125
125
@visibleForTesting
126
126
TextSpan ? lastTextSpan;
127
127
128
+ bool _disposed = false ;
129
+
128
130
late final actions = < Type , Action <Intent >> {
129
131
CommentUncommentIntent : CommentUncommentAction (controller: this ),
130
132
CopySelectionTextIntent : CopyAction (controller: this ),
@@ -233,6 +235,10 @@ class CodeController extends TextEditingController {
233
235
return ;
234
236
}
235
237
238
+ if (_disposed) {
239
+ return ;
240
+ }
241
+
236
242
analysisResult = result;
237
243
_lastAnalyzedText = codeSentToAnalysis.text;
238
244
notifyListeners ();
@@ -971,6 +977,7 @@ class CodeController extends TextEditingController {
971
977
972
978
@override
973
979
void dispose () {
980
+ _disposed = true ;
974
981
_debounce? .cancel ();
975
982
historyController.dispose ();
976
983
searchController.dispose ();
Original file line number Diff line number Diff line change @@ -261,6 +261,9 @@ class _CodeFieldState extends State<CodeField> {
261
261
disableSpellCheckIfWeb ();
262
262
263
263
WidgetsBinding .instance.addPostFrameCallback ((_) {
264
+ if (! mounted){
265
+ return ;
266
+ }
264
267
final double width = _codeFieldKey.currentContext! .size! .width;
265
268
final double height = _codeFieldKey.currentContext! .size! .height;
266
269
windowSize = Size (width, height);
@@ -312,6 +315,9 @@ class _CodeFieldState extends State<CodeField> {
312
315
void rebuild () {
313
316
setState (() {
314
317
WidgetsBinding .instance.addPostFrameCallback ((_) {
318
+ if (! mounted){
319
+ return ;
320
+ }
315
321
// For some reason _codeFieldKey.currentContext is null in tests
316
322
// so check first.
317
323
final context = _codeFieldKey.currentContext;
You can’t perform that action at this time.
0 commit comments