do thuan
do thuan

Reputation: 475

Can we set a SpanText tappable in flutter?


      RichText(
        text: TextSpan(
          text: 'NEW USER ?',
          style: TextStyle(color: Colors.grey),
          children: <TextSpan>[
            TextSpan(
              text: '  SIGN UP',
              style: TextStyle(color: Colors.blue),
            )
          ],
        ),
      ),

Here, I wanna do something when the "SIGN UP" is tapped.

Upvotes: 2

Views: 1689

Answers (1)

Darshan
Darshan

Reputation: 11669

TextSpan has recognizer property to tap on the given widget.

TextSpan(
         text: '  SIGN UP',
         style: TextStyle(color: Colors.blue),
         )    
recognizer: TapGestureRecognizer()
            ..onTap = () {
            // do something here
    }),
)

Upvotes: 5

Related Questions