Cretezy / flutter_linkify

Turns text URLs and emails into clickable inline links in text for Flutter
https://pub.dartlang.org/packages/flutter_linkify
MIT License
263 stars 99 forks source link

Linkify dont work when wrapped in CupertinoButton.filled Button #63

Closed janbildsoehansen closed 3 years ago

janbildsoehansen commented 3 years ago

Hey im new to flutter and im facing a issuse with Linkify dont work when wrapped in CupertinoButton.filled Button im i doing it wrong or..??

                          CupertinoButton.filled(
                              child: Text(landmark.hjemmeside),
                              onPressed: () {
                                Linkify(
                                  onOpen: (link) async {
                                    if (await canLaunch(link.url)) {
                                      await launch(link.url);
                                    } else {
                                      throw 'Could not launch $link';
                                    }
                                    },
                                  text: landmark.hjemmeside,
                                );
                              },
                            ),
aaqibismail commented 3 years ago

You don't need to use a button unless you want the entire text to be clickable. If you only want the hyperlink to be clickable but have the style of a button consider wrapping your Linkify in a Container and styling it like a button.

janbildsoehansen commented 3 years ago

Thanks for your answer will try that

Cretezy commented 3 years ago

@janbildsoehansen Closing as it you seem to have found the solution. Feel free to reopen!