【发布时间】:2019-05-20 04:18:33
【问题描述】:
我正在尝试从 Cloud Firestore 中获取 unicode 格式的字符串,并将其显示在我的 Flutter 应用程序中。
c。 10\u{207B}\u{2076} 秒:强子纪元开始:随着宇宙冷却到大约 10\u{00B9}\u{2070} 开尔文,发生夸克-强子转变,夸克结合形成更多复杂粒子——强子。这种夸克限制包括质子和中子(核子)的形成,它们是原子核的组成部分。
当我将它存储为字符串并在 RichText 小部件中显示时,它工作正常:
Widget _buildListItem(BuildContext context, DocumentSnapshot data) {
final record = Record.fromSnapshot(data);
String temp1 = "c. 10\u{207B}\u{2076} seconds: Hadron epoch begins: As the universe cools to about 10\u{00B9}\u{2070} kelvin, a quark-hadron transition takes place in which quarks bind to form more complex particles—hadrons. This quark confinement includes the formation of protons and neutrons (nucleons), the building blocks of atomic nuclei.";
return Padding(
key: ValueKey(record.name),
padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 8.0),
child: Container(
child: RichText(
text: TextSpan(text: temp1, style: defaultStyle),
),
),
);}
而如果我尝试将其存储在云 Firestore 上并使用相同的 RichText 小部件,它就无法正常工作。它只是按原样打印。:
Widget _buildListItem(BuildContext context, DocumentSnapshot data) {
final record = Record.fromSnapshot(data);
//String temp1 = "c. 10\u{207B}\u{2076} seconds: Hadron epoch begins: As the universe cools to about 10\u{00B9}\u{2070} kelvin, a quark-hadron transition takes place in which quarks bind to form more complex particles—hadrons. This quark confinement includes the formation of protons and neutrons (nucleons), the building blocks of atomic nuclei.";
return Padding(
key: ValueKey(record.name),
padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 8.0),
child: Container(
child: RichText(
text: TextSpan(text: record.name, style: defaultStyle),
),
),
);
}
请提供解决方案
【问题讨论】:
标签: firebase flutter google-cloud-firestore