New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deselect selectable text when clicking #25
Comments
Hi Caleb, thank you for your appreciation. Here is an example for your reference.
|
Ok thanks! This is how I ended up doing it using your advice on handling it with state. Not sure if it's the best way, but it works. class CustomSelectableText extends StatefulWidget {
const CustomSelectableText({Key? key}) : super(key: key);
@override
_CustomSelectableTextState createState() => _CustomSelectableTextState();
}
class _CustomSelectableTextState extends State<CustomSelectableText> {
bool selectable = true;
@override
Widget build(BuildContext context) {
return Focus(
onFocusChange: (focus) async {
// This will fire if I click on another widget that takes the focus
if (!focus) {
setState(() => selectable = false);
await Future.delayed(Duration(milliseconds: 100));
setState(() => selectable = true);
}
},
child: EasyRichText(
"This paragraph is selectable...",
selectable: selectable,
patternList: [
EasyRichTextPattern(
targetString: 'paragraph',
style: TextStyle(color: Colors.blue),
),
],
),
);
}
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Just want to say I love the package, it's awesome! One thing I noticed though is that text doesn't deselect. If I have it selected and then I click outside it or on another EasyRichText widget. It would be great if it could deselect to mimic the behavior that's typically expected on the web.
Let me know if you need any more details.
The text was updated successfully, but these errors were encountered: