Created
November 15, 2022 15:34
-
-
Save huynguyennovem/af55e71b1d55523fb51256cb57b582df to your computer and use it in GitHub Desktop.
A common class ClickableText using in Flutter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/gestures.dart'; | |
import 'package:flutter/material.dart'; | |
class ClickableText extends StatelessWidget { | |
final String? text; | |
final TextStyle? textStyle; | |
final Function? onTapAction; | |
const ClickableText({ | |
Key? key, | |
this.text, | |
this.textStyle, | |
this.onTapAction, | |
}) : super(key: key); | |
@override | |
Widget build(BuildContext context) { | |
return RichText( | |
text: TextSpan( | |
text: text, | |
style: textStyle ?? | |
TextStyle( | |
decoration: TextDecoration.underline, | |
color: Colors.lightBlueAccent.shade200, | |
fontSize: 16.0, | |
fontStyle: FontStyle.normal, | |
fontWeight: FontWeight.normal, | |
), | |
recognizer: TapGestureRecognizer()..onTap = () => onTapAction?.call(), | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment