huu1995vn / flutter_html_editor

MIT License
10 stars 2 forks source link

using TextEditingController in flutter_html_editor #1

Open blue492 opened 4 years ago

blue492 commented 4 years ago

Hi, Is there any way to save the String value directly from the TextField into a controller (TextEditingController) without using keyEditor.currentState.getText()

I need to use a controller because sometimes I got null value when I used this: final txt = await keyEditor.currentState.getText();

It will be good if you add it like this:

HtmlEditor(
                controller: comment_control,
                hint: "Your text here...",
                //value: "text content initial, if any",
                key: keyEditor,

                height: 400,
              ),

Thanks for good library

hason1 commented 4 years ago

I got the following error: how to fix it?

E/flutter ( 6639): [ERROR:flutter/lib/ui/ui_dart_state.cc(166)] Unhandled Exception: NoSuchMethodError: The method 'getText' was called on null.
E/flutter ( 6639): Receiver: null
E/flutter ( 6639): Tried calling: getText()
tneotia commented 3 years ago

You can use my package if you are still looking for a fix, I have controller implemented.

blue492 commented 3 years ago

@tneotia I tried your package now, but it still a problem, for example if I have a ListView with many widgets and I put your package at the beginning of the list. when I write something, then scroll down at the end of the ListView and scroll up to the package, I see that your package reload it self and the text I wrote has been removed.

The controller dont save the text automatically. In this case I need to put the package in separat page and put save button to save the text and go back to the previews page.

tneotia commented 3 years ago

Can you make a bug report in my repo with the code for your example? I think it is probably disposing the webview when it is scrolled away because there are a lot of widgets but maybe I can prevent that.