flutter_html icon indicating copy to clipboard operation
flutter_html copied to clipboard

[BUG]Can't change the background color of an iframe

Open CpHeat opened this issue 2 years ago • 3 comments

Describe the bug: Not sure if it is a bug but I understood we should be able to set styles for iframes and it works to some extent but I can't get the background-color to change to anything else than white

HTML to reproduce the issue: data: '''

<iframe width="400" src="my-widget-url" width="100%" height="120" frameBorder="0"> ''', style: { "body": Style(margin: EdgeInsets.zero, padding: EdgeInsets.zero), "iframe": Style(backgroundColor: Colors.pink), }

Expected behavior: The iframe contains a rounded widget, so the background behind it should be pink but is white instead

Device details and Flutter/Dart/flutter_html versions: API 33, flutter_html 2.2.1

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

CpHeat avatar Feb 23 '23 01:02 CpHeat

Did you try setting the pink to the iframe content? The iframe will render as WebView and I don't think it can have NO background color (be transparent) and so setting a pink background in the iframe won't work as the WebView will show a white again.

I hope I make myself clear; let us know if you need more instructions.

erickok avatar Feb 23 '23 11:02 erickok

Thanks for answering ! You mean like this :

style: { "iframe": Style(backgroundColor: Colors.blue, color: Colors.pink,), }

or inside html like this :

I tried both but it's still showing white background. Am I doing it wrong ?

CpHeat avatar Feb 23 '23 16:02 CpHeat

The WebView widget itself controls the background color. If I remember right there's an option in the WebView constructor to change the background color. If so, we can definitely tie that into our style system.

Sub6Resources avatar May 09 '23 14:05 Sub6Resources