Closed rengui-hs closed 1 year ago
See the Migration Guide
In this case, the migration would lead you to code that looks like this:
Html.fromElement(
extensions: [
TagExtension(
tagsToExtend: {"div"},
builder: (extensionContext) => const Text('Div'),
)
],
),
Although if you don't need any information from the ExtensionContext
, you don't even need a builder
, and you can do:
Html.fromElement(
extensions: [
TagExtension(
tagsToExtend: {"div"},
child: const Text('Div'),
)
],
),
Much simpler hopefully!
See the Migration Guide
In this case, the migration would lead you to code that looks like this:
Html.fromElement( extensions: [ TagExtension( tagsToExtend: {"div"}, builder: (extensionContext) => const Text('Div'), ) ], ),
Although if you don't need any information from the
ExtensionContext
, you don't even need abuilder
, and you can do:Html.fromElement( extensions: [ TagExtension( tagsToExtend: {"div"}, child: const Text('Div'), ) ], ),
Much simpler hopefully!
But I want to customize according to the class of the div, if there is no class, it will be rendered normally. Now all divs are rendered by custom.
Use builder
for sure then. In the ExtensionContext
argument of the builder
method you can access the class names of the div and render however you'd like.
I think I misunderstood your code and question, my apologies. You'll want to use a MatcherExtension
Just like this, if it matches, it will customize the rendering, if it does not match, it will parse normally.
A picture of a cute animal (not mandatory but encouraged)