[BUG] Margin does not default to Margins.zero
Describe the bug:
Setting the margin parameter to Margins.zero provide different results than not providing it at all wich differs from documentation - style.dart
HTML to reproduce the issue:
"Lorem Ipsum"
Html widget configuration:
Html(data: "Lorem Ipsum")
Html(
data: "Lorem Ipsum",
style: {
"*": Style(
margin: Margins.zero,
),
},
),
Expected behavior:
Text should be rendered without any margin in both cases
Screenshots:
Additional info:
This problem has been referenced before - https://github.com/Sub6Resources/flutter_html/issues/1053, but never fixed
As documented elsewhere, the body tag includes margins by default (the same as any modern web browser). What needs to be better documented in this package is that html snippets are automatically wrapped in html and body tags in order to form a valid html document. Many block-level html elements (h1, p, etc.) include some sort of default margin or padding as described in the CSS spec.
The documentation in style.dart refers to new Style instances, however CSS inheritance can cause these default values to be overwritten by parent element's styles.
This should be better documented, sorry!
I totally agree, but it becomes a little problematic when using Style.fromTextStyle. One could assume the text should behave in the same way the Flutter Text Widget does, but as you have already stated proper documentation is key.