AlertDialog 内容未显示任何文本

时间:2021-05-20 20:56:15

标签: flutter

我有一个 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()),
            ],
          );

但它最终是空白的:

enter image description here

有人知道我做错了什么吗?

1 个答案:

答案 0 :(得分:1)

这会很愚蠢,但我也不知道为什么我的应用会这样做...

颜色是白色的,所以它混合了。我必须将我的 TextSpan 设置为白色以外的颜色。

?