1
0
Fork 0
forked from Nexus/nexus
nexus/lib/widgets/linkified_text.dart
Henry-Hiles d2ec5f035b
treewide: use dot shorthands where possible
Now this feature is stable, we should use it. I might have missed some usecases, but these can be added in future commits.
2026-06-02 12:50:56 -04:00

23 lines
781 B
Dart

import "package:flutter/material.dart";
import "package:flutter_linkify/flutter_linkify.dart";
import "package:flutter_riverpod/flutter_riverpod.dart";
import "package:nexus/helpers/launch_helper.dart";
class LinkifiedText extends ConsumerWidget {
final String text;
final int? maxLines;
final TextStyle? style;
const LinkifiedText(this.text, {this.maxLines, this.style, super.key});
@override
Widget build(BuildContext context, WidgetRef ref) => Linkify(
text: text,
maxLines: maxLines,
style: style,
options: .new(humanize: false),
onOpen: (link) =>
ref.watch(LaunchHelper.provider).launchUrl(.parse(link.url)),
linkStyle: .new(color: Theme.of(context).colorScheme.primary),
overflow: maxLines == null ? null : .ellipsis,
);
}