flutter_flow_chart icon indicating copy to clipboard operation
flutter_flow_chart copied to clipboard

Text Editor Bug/Crash

Open bl12345 opened this issue 2 years ago • 2 comments

Hello Marco,

We notice when using your flutter_flow_chart, that when attempting to input text into an object, the editor quickly closes (before we can input any text), due to the following exception (see below):

Note: The exception below can cause the flutter app (consisting solely of your code example) to crash (please see attached video Bug-Crash.mp4 for more information).

https://user-images.githubusercontent.com/33987270/203934265-b4b59bc5-0f3d-44b7-bb6a-35f1156af026.mp4

`======== Exception caught by scheduler library ============================================== The following assertion was thrown during a scheduler callback: Cannot get renderObject of inactive element.

In order for an element to have a valid renderObject, it must be active, which means it is part of the tree. Instead, this element is in the _ElementLifecycle.defunct state. If you called this method from a State object, consider guarding it with State.mounted. The findRenderObject() method was called for the following element: StatefulElement#6d185(DEFUNCT) no widget When the exception was thrown, this was the stack: #0 Element.findRenderObject. (package:flutter/src/widgets/framework.dart:4093:9) #1 Element.findRenderObject (package:flutter/src/widgets/framework.dart:4106:6) #2 StarMenuState._showMenu (package:star_menu/src/star_menu.dart:387:36) #3 StarMenuState.showMenu (package:star_menu/src/star_menu.dart:375:7) #4 StarMenuState.resetForChanges (package:star_menu/src/star_menu.dart:236:7) #5 StarMenuState.didChangeMetrics. (package:star_menu/src/star_menu.dart:221:7) #6 SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1175:15) #7 SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1113:9) #8 SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:1015:5) #9 _invoke (dart:ui/hooks.dart:148:13) #10 PlatformDispatcher._drawFrame (dart:ui/platform_dispatcher.dart:318:5) #11 _drawFrame (dart:ui/hooks.dart:115:31) ==============================================================================`

Thank you for any help you can provide.

bl12345 avatar Nov 25 '22 08:11 bl12345

Hi,

thanks for your helpful video!! Seems like the problem comes from StarMenu package! Since I wrote that package I can do something I hope! In the week end I'll look into that.

alnitak avatar Nov 25 '22 17:11 alnitak

Hello Marco,

Thank you for all your help.

bl12345 avatar Nov 25 '22 18:11 bl12345

posted a fix for the bounty, hope it helps.

gitgudyyao avatar Jan 04 '23 05:01 gitgudyyao

Hi @gitgudyyao , it's always a good practice to check the mounted state! :) I have merged your PR, seems to fix the problem. For now should be better to manage the text change without using the StarMenu. Anyway, I still need to check the StarMenu package because the main problem comes from that with this issue. Thank you

alnitak avatar Jan 04 '23 16:01 alnitak

Hello @alnitak ,

Apologies for not responding sooner.

I believe you are correct, StarMenu is still leading to problems.

I just updated all my Flutter packages (picked up the new update), and though I don't see the same exception, I still see the same behavior (i.e., the keyboard window closes before I can type anything).

For now, the current exception is the following:

======== Exception caught by scheduler library ===================================================== E/flutter (31108): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: 'package:flutter/src/widgets/overlay.dart': Failed assertion: line 161 pos 12: '_overlay != null': is not true. E/flutter (31108): #0 _AssertionError._doThrowNew (dart:core-patch/errors_patch.dart:51:61) E/flutter (31108): #1 _AssertionError._throwNew (dart:core-patch/errors_patch.dart:40:5) The following assertion was thrown during a scheduler callback: Cannot get renderObject of inactive element. E/flutter (31108): #2 OverlayEntry.remove (package:flutter/src/widgets/overlay.dart:161:12)

Thank you for all your help.

bl12345 avatar Jan 06 '23 03:01 bl12345