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

huangapple go评论54阅读模式
英文:

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 a new line character - as shown below:
AWS Amplify DataStore displaying as-it-is string data with '\n' (New line character) without creating a new line in Flutter 'Text' class

In my Flutter App, I wanted to show data in a new line using Flutter 'Text' class, but instead, I'm getting the data retrieved from AWS Amplify as shown below:
AWS Amplify DataStore displaying as-it-is string data with '\n' (New line character) without creating a new line in Flutter 'Text' class

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

英文:

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:
AWS Amplify DataStore displaying as-it-is string data with '\n' (New line character) without creating a new line in Flutter 'Text' class

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:
AWS Amplify DataStore displaying as-it-is string data with '\n' (New line character) without creating a new line in Flutter 'Text' class

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

答案1

得分: 1

尝试这个:

Text(
'subtitle'.replaceAll('\\n', '\n'),
)
英文:

Try this:

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

huangapple
  • 本文由 发表于 2023年4月19日 17:37:06
  • 转载请务必保留本文链接:https://go.coder-hub.com/76052969.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定