0

I am developing a mobile app using flutter. It should have a text field like this. enter image description here

From this input field I want to get input as a normal text with given controls and want to store it in the form of HTML. For example consider below text.

Hi this is my title
This is sample text

I want to store it my database in the form of HTML like bellow.

<b>Hi this is my title</b><br>
<i>This is sample text</i>

How can I do this using flutter?

1 Answer 1

1

For simple html tags like above you can use the styled_text package.

StyledText(
  text: text.replaceAll("<br>", "\n"),
  tags: {
    'b': StyledTextTag(style: TextStyle(fontWeight: FontWeight.bold)),
    'i': StyledTextTag(style: TextStyle(fontStyle: FontStyle.italic))
  },
);

link: https://pub.dev/packages/styled_text

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks. It is a use full package for me. But I don't know where the user will use bold, italic kind of things. Is it possible to combine those all together as single variable at the end?. I mean can I take an output like below? <b> Hi </b> how are you. <i> I am busy with work</i> <br> We will meet tomorrow. Can i get whole this as on input variable at the end? I don't know where the user use these tags.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.