flutter_html icon indicating copy to clipboard operation
flutter_html copied to clipboard

[QUESTION] Migrate to version 3

Open Sembauke opened this issue 2 years ago • 4 comments

Hey I can't find anything about migrating to version 3 from 2 I wish to change my custom rendered tags to the new format. Here is an example:

'blockquote': (code, child) {
          return Container(
            decoration: const BoxDecoration(
              border: Border(
                left: BorderSide(
                    color: Color.fromRGBO(0x99, 0xc9, 0xff, 1), width: 2),
              ),
            ),
            child: child,
          );
        }

Sembauke avatar Jun 27 '22 12:06 Sembauke

I have the same problem.

moNiti avatar Jul 03 '22 08:07 moNiti

I ended up doing it like this @moNiti

blockQuoteMatcher(): CustomRender.widget(widget: (code, child) {
      return Container(
        decoration: const BoxDecoration(
          border: Border(
            left: BorderSide(
                color: Color.fromRGBO(0x99, 0xc9, 0xff, 1), width: 2),
          decoration: const BoxDecoration(
            border: Border(
              left: BorderSide(
                  color: Color.fromRGBO(0x99, 0xc9, 0xff, 1), width: 2),
            ),
          ),
        ),
        child: child,
      );
    }
   
    
CustomRenderMatcher blockQuoteMatcher() =>
(context) => context.tree.element?.localName == 'blockquote';
      
      
      
        

Sembauke avatar Jul 03 '22 09:07 Sembauke

But the child in parameter is not widget type The argument type 'List<InlineSpan> Function()' can't be assigned to the parameter type 'Widget?


flutter_html: 3.0.0-alpha.5

moNiti avatar Jul 03 '22 10:07 moNiti

Yes, I forgot to add that in my example:

  1. add a Row widget
  2. Make a for-loop that checks for the number of new lines: for (var line in code.tree.element!.text.split('\n'))
  3. Put your line in an expanded and a Text widget

You can set the style of the text like font-size: textStyle: TextStyle(fontSize: code.style.fontSize!.size)

Sembauke avatar Jul 03 '22 10:07 Sembauke

Migration guide has been added at https://github.com/Sub6Resources/flutter_html/wiki/Migration-Guides#300

Sub6Resources avatar May 13 '23 18:05 Sub6Resources