flutter 实现 文字中插入图标并能够点击

Container(
                                  padding:
                                      EdgeInsets.only(left: 8.0, right: 12.0),
                                  child: Text.rich(
                                    TextSpan(
                                      style: TextStyle(
                                        fontSize: 12,
                                      ),
                                      recognizer: TapGestureRecognizer()
                                        ..onTap = () async {
                                          print('-->>>>>>>>>-');
                                        },
                                      children: [
                                        TextSpan(
                                            text:
                                                '如客户是你的微信好友,可复制昵称到微信搜索,开启会话。 ',
                                            style: TextStyle(
                                                fontSize: 12.0,
                                                color: Color(0xB2FFFFFF))),
                                        WidgetSpan(
                                            child: SizedBox(
                                          height: 23.0,
                                           23.0,
                                          child:InkWell(
                                            onTap: (){
                                              print('---------------------');
                                            },
                                            child:  Card(
                                                child: Center(
                                                  child: Icon(
                                                    IconData(0xe63c,
                                                        fontFamily: 'saas'),
                                                    size: 12.0,
                                                    color: Colors.black,
                                                  ),
                                                )),
                                          )
                                        ))
                                      ],
                                    ),
                                  )
                                  // Text(
                                  //   "如客户是你的微信好友,可复制昵称到微信搜索,开启会话。",
                                  //   style: TextStyle(
                                  //       fontSize: 12.0, color: Color(0xB2FFFFFF)),
                                  // ),
                                  )),

效果

原文地址:https://www.cnblogs.com/lymconch/p/14117772.html