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

SelectableLinkify Error span #79

Closed Larens94 closed 3 years ago

Larens94 commented 3 years ago

Hi, why are you sending me this error?

The following assertion was thrown building SelectableText(dirty, state: _SelectableTextState#d1317): SelectableText only supports TextSpan; Other type of InlineSpan is not allowed 'package:flutter/src/material/selectable_text.dart': Failed assertion: line 560 pos 12: '() { return _controller._textSpan.visitChildren((InlineSpan span) => span.runtimeType == TextSpan); }()' Schermata 2021-03-07 alle 16 03 12

MohamedEL-Torky commented 3 years ago

same

flutter: ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════ flutter: The following assertion was thrown building SelectableText(scrollPhysics: flutter: NeverScrollableScrollPhysics, dirty, state: _SelectableTextState#14ce5): flutter: SelectableText only supports TextSpan; Other type of InlineSpan is not allowed flutter: 'package:flutter/src/material/selectable_text.dart': flutter: Failed assertion: line 560 pos 12: '() { flutter: return _controller._textSpan.visitChildren((InlineSpan span) => span.runtimeType == TextSpan); flutter: }()' flutter: flutter: Either the assertion indicates an error in the framework itself, or we should provide substantially flutter: more information in this error message to help you determine and fix the underlying cause. flutter: In either case, please report this assertion by filing a bug on GitHub: flutter: https://github.com/flutter/flutter/issues/new?template=2_bug.md flutter: flutter: The relevant error-causing widget was: flutter: SelectableLinkify

MohamedEL-Torky commented 3 years ago

I have requested a pull request with the fix for this issue, until then you can use my fork as your package to bypass this issue.

  flutter_linkify:
    git:
      url: https://github.com/MohamedEL-Torky/flutter_linkify
blono commented 3 years ago

@MohamedEL-Torky God was here...

echomartha commented 3 years ago

@MohamedEL-Torky Thanks!!

deacon78 commented 3 years ago

Hello MohamedEL-Torky This solves the issue, thanks.

But there is still this issue with selectableLinkify : "textScaleFactor" is not handled :(

MohamedEL-Torky commented 3 years ago

@deacon78 I've updated my fork for your use case, now you can use textScaleFactor inside SelectableLinkify. Do flutter clean then flutter pub get and tell me if you face any problems.

deacon78 commented 3 years ago

Mohamed, thank you very much

MohamedEL-Torky commented 3 years ago

You're very welcome anytime.

deacon78 commented 3 years ago

Sorry but this still doesn't work

SelectableLinkify( onOpen: (link) async { if (await canLaunch(link.url)) { await launch(link.url); } else { throw 'Could not launch $link'; } }, text: this.entretien.noteEntretien, textScaleFactor: 1.0,//not handled :( style:TextStyle(fontFamily: "BerlinSansFBRegular",fontSize: getFontSize(1,context),), options: LinkifyOptions(humanize: false),//pour afficher le http ),

I got the error : textScaleFactor isn't defined

MohamedEL-Torky commented 3 years ago

This seems to be a local cache issue, try removing the package from the pubspec.yaml and then do flutter clean and then flutter pub get, after that add the package again in the pubspec and do a flutter pub get.

deacon78 commented 3 years ago

It works with your tip.

A big thank you !

RedyAu commented 3 years ago

@MohamedEL-Torky Your fix worked with our app too, but I noticed, the resulting text size is quite small, I don't think it follows the rest of the app. I may be wrong tho. Could there be any reason for this? Btw, as many have said before me, thank you for this fix, I hope your PR gets merged soon.

Cretezy commented 3 years ago

This appears to be fixed with #80, which has a remaining requested change. Will merge ASAP

Aanu1995 commented 3 years ago

@Cretezy Thank you for the package. I just tested the latest version released few hours ago and this issue of SelectableLinkifyError still remain unfixed.

can you please look into the current pull request? The issue was fixed in that pull request and I would have used it but it seems to have a conflict with one of the packages am using. Thank you

Cretezy commented 3 years ago

@Aanu1995 See my previous comment, PR #80 has comments to be addressed before merging. As soon as they are fixed, I will deploy a new version

Cretezy commented 3 years ago

Just released 5.0.2 with this a fix for this.