【问题标题】:AlertDialog content isn't showing any textAlertDialog 内容未显示任何文本
【发布时间】:2021-08-10 03:32:21
【问题描述】:

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

但它最终是空白的:

有谁知道我做错了什么?

【问题讨论】:

    标签: flutter


    【解决方案1】:

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

    颜色是白色的,所以它融入其中。我必须将我的TextSpan 设置为白色以外的颜色。

    ?

    【讨论】:

    • 只是猜测:您的测试设备暗模式是否已打开?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-08-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多