我正在尝试使用换行命令在文本中创建新行。从这个问题看来,这是不可能的:New Line Command (\n) Not Working With Firebase Firestore Database Strings
现在还是这样吗?假设是这样,Flutter 是否提供了与以下功能类似的任何方法来解决这个问题?
label.text = stringRecived.replacingOccurrences(of: "\n", with: "\n")
Run Code Online (Sandbox Code Playgroud)
*更多上下文:这是我输入数据的 Firestore 字符串的图片。

然后我使用未来的构建器从 Firestore 调用它,然后将字符串(在本例中为注释)传递给另一个小部件。
return new SocialFeedWidget(
filter: false,
articleID: document['article'],
article_header: document['article_title'],
userName: document['author'],
spectrumValue: document['spectrum_value'].toDouble(),
comment: document['comment'],
fullName: document['firstName'] + " " + document['lastName'],
user_id: document['user_id'],
postID: document.documentID,
posterID: userID,
);
}).toList(),
Run Code Online (Sandbox Code Playgroud)
在新的小部件中,我将它作为字符串传入并通过 Text 小部件提供,如下所示:
new Text(
comment,
style: new TextStyle(
color: Color.fromRGBO(74, 74, 74, 1.0),
fontSize: 13.0,
),
),
Run Code Online (Sandbox Code Playgroud)