Sub6Resources / flutter_html

A Flutter widget for rendering static html as Flutter widgets (Will render over 80 different html tags!)
https://pub.dev/packages/flutter_html
MIT License
1.79k stars 860 forks source link

[BUG] HTML not picking these Tags \n\n and /r #1151

Closed marslannasr7koncepts closed 1 year ago

marslannasr7koncepts commented 1 year ago

This '50s-inspired diner on Carson Street is a blast from the past, decked out with classic checkered tiles, vinyl bar stools and booths made from the backs of Golden Era cars. What was once the Lakewood Broiler and Sunny Spot has been known as Dale’s Diner since 1988 and been a Long Beach mainstay since. Old school malts and shakes are available with classic American-style diner cuisine, such as big burgers and pancakes served in generous portions. The nostalgia trip is a great choice for breakfast, lunch or dinner. Favorites include the southwest and cajun burgers, club and BLT sandwiches and salisbury steak. \n\nWe are testing

Sample text added above when trying to show within the app /n/n not adding next line space instead showing within the same Line.

Sub6Resources commented 1 year ago

This is intended behavior. As in HTML, extra whitespace is ignored by default.

In order to preserve whitespace, you must do the following:

Html(
  data: htmlData,
  style: {
    "body": Style( // You can replace "body" with a specific HTML tag or CSS selector if needed
      whiteSpace: WhiteSpace.PRE, // Although it'll be "WhiteSpace.pre" in 3.0.0-alpha.6 and later
    ),
  },
),
marslannasr7koncepts commented 1 year ago

Hi @Sub6Resources can you tell me about use of whiteSpace: WhiteSpace.PRE this style what it will do ?

Sub6Resources commented 1 year ago

@marslannasr7koncepts WhiteSpace.PRE causes \n characters to not be removed when processing the HTML input. (By default in HTML, \n characters are converted to a space or removed).