glynskyi / zefyrka

Soft and gentle rich text editing for Flutter applications
MIT License
110 stars 74 forks source link

fixes null check error on _textInputConnection #45

Closed jason-downs closed 2 years ago

jason-downs commented 2 years ago

This fixes an error where _textInputConnection! was assumed non-null in RawEditorStateTextInputClientMixin._updateSizeAndTransform, but was producing an error because it in fact was null.

image

This seems to be because even though it checks hasConnection at the beginning of _updateSizeAndTransform function, before the post-frame callback actually executes the connection is lost and thus _textInputConnection is no longer guaranteed to be non-null when the ! is used. I think this is happening because in my own app where zefyrka is being used, when you navigate back tot the zefyrka page from somewhere else it is doing additional things using post-frame callbacks that take the focus off of the zefyrka editor. I'm not completelly sure what the exact chain of events is, but adding this additional check, although somewhat redundant, prevents the error from happening and does not have any side effects that I can see.