Skip to content

[FEATURE] Handling width-height with percentage #1185

@mirkancal

Description

@mirkancal

Describe your feature request
I see that flutter_html_iframe tries to parse width and height but fails when it contains "%".
I think this kind of width and height values can use MediaQuery.of(context.buildContext).size.height or width.

Here's my "not so clean at the moment" solution for it.

 final num? isPercentWidthValue =
          context.tree.element?.attributes['width']?.contains('%') ?? false
              ? double.tryParse(context.tree.element?.attributes['width']!
                      .replaceAll('%', '') ??
                  '')
              : null;
 return Container(
   width: isPercentWidthValue != null
            ? MediaQuery.of(context.buildContext).size.width *
                isPercentWidthValue /
                100
            : givenWidth ?? (givenHeight ?? 150) * 2,
            ...

Let me know what you guys think.

Additional context

A picture of a cute animal (not mandatory but encouraged)

Metadata

Metadata

Assignees

No one assigned

    Labels

    <iframe>Issues with the <iframe> tagenhancementNew feature or request

    Projects

    Status

    Todo

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions