Flutter TextSpan中的手势检测 [英] Gesture detection in Flutter TextSpan

查看:599
本文介绍了Flutter TextSpan中的手势检测的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以检测到用户触摸了TextSpan中的哪个单词?

Is there a way to detect which word in the TextSpan was touched by the user?

此段是为了绕过堆栈溢出机器人,该机器人坚持要求我写更多的东西:)

This paragraph is here to get round the stack overflow robot that is insisting that I write more stuff :)

推荐答案

您可以自己改善

import 'package:flutter/gestures.dart';
...

new RichText(
      text: new TextSpan(text: 'Non touchable. ', children: [
        new TextSpan(
          text: 'Tap here.',
          recognizer: new TapGestureRecognizer()..onTap = () => print('Tap Here onTap'),
        )
      ]),
    );

这篇关于Flutter TextSpan中的手势检测的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆