parent
4848840538
commit
e69f04f6e7
7 changed files with 105 additions and 41 deletions
23
lib/widgets/linkified_text.dart
Normal file
23
lib/widgets/linkified_text.dart
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
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: LinkifyOptions(humanize: false),
|
||||
onOpen: (link) =>
|
||||
ref.watch(LaunchHelper.provider).launchUrl(Uri.parse(link.url)),
|
||||
linkStyle: TextStyle(color: Theme.of(context).colorScheme.primary),
|
||||
overflow: maxLines == null ? null : TextOverflow.ellipsis,
|
||||
);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue