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 {
125125 @visibleForTesting
126126 TextSpan ? lastTextSpan;
127127
128+ bool _disposed = false ;
129+
128130 late final actions = < Type , Action <Intent >> {
129131 CommentUncommentIntent : CommentUncommentAction (controller: this ),
130132 CopySelectionTextIntent : CopyAction (controller: this ),
@@ -233,6 +235,10 @@ class CodeController extends TextEditingController {
233235 return ;
234236 }
235237
238+ if (_disposed) {
239+ return ;
240+ }
241+
236242 analysisResult = result;
237243 _lastAnalyzedText = codeSentToAnalysis.text;
238244 notifyListeners ();
@@ -971,6 +977,7 @@ class CodeController extends TextEditingController {
971977
972978 @override
973979 void dispose () {
980+ _disposed = true ;
974981 _debounce? .cancel ();
975982 historyController.dispose ();
976983 searchController.dispose ();
Original file line number Diff line number Diff line change @@ -266,6 +266,9 @@ class _CodeFieldState extends State<CodeField> {
266266 disableSpellCheckIfWeb ();
267267
268268 WidgetsBinding .instance.addPostFrameCallback ((_) {
269+ if (! mounted){
270+ return ;
271+ }
269272 final double width = _codeFieldKey.currentContext! .size! .width;
270273 final double height = _codeFieldKey.currentContext! .size! .height;
271274 windowSize = Size (width, height);
@@ -317,6 +320,9 @@ class _CodeFieldState extends State<CodeField> {
317320 void rebuild () {
318321 setState (() {
319322 WidgetsBinding .instance.addPostFrameCallback ((_) {
323+ if (! mounted){
324+ return ;
325+ }
320326 // For some reason _codeFieldKey.currentContext is null in tests
321327 // so check first.
322328 final context = _codeFieldKey.currentContext;
You can’t perform that action at this time.
0 commit comments