fluttertextaws-amplifydatastoreflutter-text

AWS Amplify DataStore displaying as-it-is string data with '\n' (New line character) without creating a new line in Flutter 'Text' class


I've a small doubt on displaying data through AWS Amplify DataStore.

I've the below model in schema.graphql

type ItemFaq @model @auth(rules: [{allow: public}]) {
  id: ID!
  indexItemFaq: Int
  titleItemFaq: String
  subtitleItemFaq: String
} 

I've deployed data model in AWS Amplify and updated sample data with new line character - as shown below: enter image description here

In my Flutter App, I wanted to show data in newline using Flutter 'Text' class, but instead I'm getting the data retrieved from AWS Amplify as shown below: enter image description here

How can I make use of Flutter 'Text' class to show data in new line when retrieving data from AWS Amplify?


Solution

  • Try this:

    Text(
    'subtitle'.replaceAll('\\n', '\n'),
    ),