LinkTextSpan constructor

LinkTextSpan({
  1. TextStyle? style,
  2. required Uri url,
  3. String? text,
  4. LinkTapHandler? onLinkTap,
  5. List<InlineSpan>? children,
})

Implementation

LinkTextSpan(
    {TextStyle? style,
    required this.url,
    String? text,
    this.onLinkTap,
    List<InlineSpan>? children})
    : super(
        style: style,
        text: text ?? '',
        children: children ?? <InlineSpan>[],
        recognizer: TapGestureRecognizer()
          ..onTap = () async {
            if (onLinkTap != null) {
              onLinkTap(url);
              return;
            }
            if (await canLaunchUrl(url)) {
              await launchUrl(url);
            } else {
              throw 'Could not launch $url';
            }
          },
      ) {
  _fixRecognizer(this, recognizer!);
}