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 @@ -266,6 +266,9 @@ class _CodeFieldState extends State<CodeField> {
266
266
disableSpellCheckIfWeb ();
267
267
268
268
WidgetsBinding .instance.addPostFrameCallback ((_) {
269
+ if (! mounted){
270
+ return ;
271
+ }
269
272
final double width = _codeFieldKey.currentContext! .size! .width;
270
273
final double height = _codeFieldKey.currentContext! .size! .height;
271
274
windowSize = Size (width, height);
@@ -317,6 +320,9 @@ class _CodeFieldState extends State<CodeField> {
317
320
void rebuild () {
318
321
setState (() {
319
322
WidgetsBinding .instance.addPostFrameCallback ((_) {
323
+ if (! mounted){
324
+ return ;
325
+ }
320
326
// For some reason _codeFieldKey.currentContext is null in tests
321
327
// so check first.
322
328
final context = _codeFieldKey.currentContext;
You can’t perform that action at this time.
0 commit comments