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
262 stars 99 forks source link

Conflicting Semantics causes crash #128

Open jwehrle opened 7 months ago

jwehrle commented 7 months ago

Error: 'package:flutter/src/semantics/semantics.dart': Failed assertion: line 3184 pos 16: 'node.parent == null || !node.parent!.isPartOfNodeMerging || node.isMergedIntoParent': is not true.

I copy pasted the example code as the title of a ListTile and the error above is thrown.

   ListTile(
      leading: leading,
      title: Linkify(
        onOpen: (link) async {
          if (!await launchUrl(Uri.parse(link.url))) {
            throw Exception('Could not launch ${link.url}');
          }
        },
        text: "Made by https://cretezy.com",
        style: TextStyle(color: Colors.yellow),
        linkStyle: TextStyle(color: Colors.red),
      ),
      trailing: trailing,
    )

Unless I wrap Linkify in ExcludeSemantics:

   ListTile(
      leading: leading,
      title: ExcludeSemantics(
        child: Linkify(
          onOpen: (link) async {
            if (!await launchUrl(Uri.parse(link.url))) {
              throw Exception('Could not launch ${link.url}');
            }
          },
          text: "Made by https://cretezy.com",
          style: TextStyle(color: Colors.yellow),
          linkStyle: TextStyle(color: Colors.red),
        ),
      ),
      trailing: trailing,
    )

The idea for this came from https://github.com/flutter/flutter/issues/31437

Which suggests there is a conflict between the ListTile semantics and the RichText semantics in Linkify.

Excluding semantics is not a good option for my app and I'd rather not have to replicate ListTile to use Linkify.

Has anyone else run into this problem?