首页 > 解决方案 > 颤振:如何创建带有链接和可点击图标的文本小部件

问题描述

如何在颤动中创建下面的图片。我尝试使用 Richtext 和小部件跨度(可单击图标),但在小部件跨度方面出现错误.. 是否有另一种方法可以在没有小部件跨度的情况下使用不同的布局

这是我的代码

Expanded(
          child: RichText(
            text: new TextSpan(
              children: [
                TextSpan(
                  text:
                      'Email me career-related  updates and job opportunities. company  ',
                  style: TextStyle(
                      color: Palette.DARK_BLUE, fontSize: 16.0),
                ),
                TextSpan(
                  text: 'privacy policy',
                  style: TextStyle(
                      color: Palette.DARK_BLUE,
                      fontSize: 16.0,
                      decoration: TextDecoration.underline),
                  recognizer: TapGestureRecognizer()
                    ..onTap = () {
                      launch('https://www.google.com');
                    },
                ),
                TextSpan(
                  text: ' and ',
                  style: TextStyle(
                      color: Palette.DARK_BLUE, fontSize: 16.0),
                ),
                TextSpan(
                  text: 'terms of use ',
                  style: TextStyle(
                      color: Palette.DARK_BLUE,
                      fontSize: 16.0,
                      decoration: TextDecoration.underline),
                  recognizer: TapGestureRecognizer()
                    ..onTap = () {
                      launch('https://www.google.com/');
                    },
                ),
                WidgetSpan(
                  child: Container(
                    child: Icon(
                      Icons.info_outline,
                      color: Colors.red,
                    ),
                  ),
                )
              ],
            ),
          ),
        ),

在此处输入图像描述

标签: flutter

解决方案


推荐阅读