我有一个 AlertDialog
,我想在文本中添加超链接。这是我目前拥有的:
await showDialog(
context: context,
barrierDismissible: true,
builder: (BuildContext context) => AgreementDialog());
// AgreementDialog.dart
build(BuildContext context) {
return StreamBuilder(
stream: agreementBloc.agreements,
builder:
(BuildContext context, AsyncSnapshot<AgreementDocuments> snapshot) {
if (snapshot.hasError) {
SnackBars.errorSnackBar(context, snapshot.error.toString());
return Spinner();
}
if (!snapshot.hasData) {
return Spinner();
}
return AlertDialog(
title: Text('Wait'),
content: Text('test tes test'),
actions: <Widget>[
TextButton(
child: Text('Approve'),
onPressed: () => Navigator.of(context).pop()),
],
);
});
}
以上工作并会呈现 'test tes test'
,但现在当我尝试使用解决方案 here 时,我根本看不到 content
文本。这是我尝试过的:
return AlertDialog(
title: Text('One second...'),
content: RichText(
text: TextSpan(children: [
TextSpan(text: 'By clicking Agree, I hereby agree to the '),
TextSpan(text: 'Blah blah blah'),
]),
),
actions: <Widget>[
TextButton(
child: Text('Approve'),
onPressed: () => Navigator.of(context).pop()),
],
);
但它最终是空白的:
有人知道我做错了什么吗?
答案 0 :(得分:1)
这会很愚蠢,但我也不知道为什么我的应用会这样做...
颜色是白色的,所以它混合了。我必须将我的 TextSpan
设置为白色以外的颜色。
?