How to change textStyle of HtmlEditor? execCommand works but it works wrong. Flutter, html_editor_enhanced

84 Views Asked by At

I use HtmlEditor widget in my project. This editor coming from html_editor_enhanced package. I need to change the text style of the text I write in the editor. I tried many ways but these are not work correctly. Finally I changed, but it isn't plusJakartaSans How can I set GoogleFonts.plusJakartaSans textStyle to text in editor?

Here Codes:

HtmlEditor(
   controller: editorController,
   htmlToolbarOptions: HtmlToolbarOptions(
     toolbarType: ToolbarType.nativeGrid,
     buttonColor: Colors.black,
     defaultToolbarButtons: const [
       FontButtons(clearAll: false, strikethrough: false, subscript: false, superscript: false), 
       ColorButtons(),
       ListButtons(listStyles: false)
     ],
    textStyle: ThemeConstants().getDescriptionTextStyle(context)
   ),
   htmlEditorOptions: HtmlEditorOptions(
     adjustHeightForKeyboard: false,
     shouldEnsureVisible: false,
   ),
   callbacks: Callbacks(
     onFocus: () {
       //Change the text style of editor
       if(biography == null || (biography != null && biography!.splitHtmlText() == 0)){
         editorController.execCommand(
         'fontName', argument: GoogleFonts.plusJakartaSans().fontFamily
         );
       }
     },
  ),
),

Display like that: (I need same style with editor title (Biyografi), but isn't same with that) See the text and title

I tried:

  • I loaded the font asset which I wanted to make into my project and ran it by running pub get. But not works.
  • I tried by giving import link with css code, not works too.
  • I defined onFocus callback with editorController.execCommand, wrong style came.
0

There are 0 best solutions below