Skip to content

[BUG] Simple non-wrapped children are not rendered #1252

@michalsrutek

Description

@michalsrutek

Describe the bug:

When using customRenders, simple non-wrapped text does not get rendered. It has to be wrapped in p, span or similar.

HTML to reproduce the issue:

<custom>Hello <span>there</span> <test></test> <p>new</p></custom>

Html widget configuration:

import 'package:flutter/material.dart';
import 'package:flutter_html/flutter_html.dart';

class HtmlApp extends StatelessWidget {
  const HtmlApp({super.key});

  final _testTag = 'test';
  final _customWrapperTag = 'custom';

  CustomRender _testRender() {
    return CustomRender.widget(widget: (_, __) {
      return const Icon(Icons.abc);
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('HTML example'),
        ),
        body: Html(
          data:
              '<custom>Hello <span>there</span> <test></test> <p>new</p></custom>',
          customRenders: {
            tagMatcher(_testTag): _testRender(),
            tagMatcher(_customWrapperTag): fallbackRender(),
          },
          tagsList: Html.tags
            ..addAll([
              _testTag,
              _customWrapperTag,
            ]),
        ),
      ),
      debugShowCheckedModeBanner: false,
    );
  }
}

Expected behavior:

I would expect the word Hello to be rendered. But it is not - as it does not appear in the buildChildren function. If I comment out the following line, it works as expected.

tagMatcher(_customWrapperTag): fallbackRender(),

Is this the correct behavior - am I just missing something?

Screenshots:

Expected Actual
Simulator Screen Shot - iPhone 14 Pro - 2023-05-08 at 12 13 19 Simulator Screen Shot - iPhone 14 Pro - 2023-05-08 at 12 13 27

Device details and Flutter/Dart/flutter_html versions:

  • Device: any
  • Flutter 3.7.12
  • Dart 2.19.6
  • flutter_html 3.0.0-alpha.6

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions