linked_text 1.0.0 copy "linked_text: ^1.0.0" to clipboard
linked_text: ^1.0.0 copied to clipboard

A Flutter widget that renders text with interpolated tappable links using a simple template syntax.

linked_text #

CI pub package

A Flutter widget that renders text with interpolated tappable links using a simple template syntax.

Features #

  • Simple template syntax for embedding links in text
  • Auto-indexed ({{link}}) and explicitly indexed ({N{link}}) placeholders
  • Default URL launching via url_launcher or custom onTap callback
  • Semantic labels for accessibility
  • Customizable text and link styles
  • Proper gesture recognizer lifecycle management

Installation #

dependencies:
  linked_text: ^1.0.0

Usage #

LinkedText(
  text: 'Visit the {{Flutter website}} for more info.',
  urls: ['https://flutter.dev'],
  urlLabels: ['Link to Flutter website'],
)

Un-indexed placeholders are automatically assigned sequential indices:

LinkedText(
  text: '{{Privacy Policy}} | {{Terms of Service}}',
  urls: [
    'https://example.com/privacy',
    'https://example.com/terms',
  ],
  urlLabels: [
    'Link to Privacy Policy',
    'Link to Terms of Service',
  ],
)

Use {N{text}} syntax (1-based) to control which URL each placeholder maps to:

LinkedText(
  text: 'Built with {1{Flutter}}, powered by {2{Dart}}.',
  urls: [
    'https://flutter.dev',
    'https://dart.dev',
  ],
  urlLabels: [
    'Link to Flutter',
    'Link to Dart',
  ],
)

Custom tap handling #

LinkedText(
  text: 'Read the {{documentation}}.',
  urls: ['https://example.com/docs'],
  urlLabels: ['Link to documentation'],
  onTap: (url, index) {
    // Custom handling instead of launching URL
    print('Tapped link $index: $url');
  },
)

Custom styles #

LinkedText(
  text: 'Check out {{this link}}.',
  urls: ['https://example.com'],
  urlLabels: ['Example link'],
  style: TextStyle(fontSize: 14, color: Colors.grey),
  linkStyle: TextStyle(
    fontSize: 14,
    color: Colors.blue,
    decoration: TextDecoration.underline,
  ),
  textAlign: TextAlign.center,
)

Template Syntax #

Syntax Description Example
{{text}} Auto-indexed link (0-based, sequential) {{Click here}}
{N{text}} Explicitly indexed link (N is 1-based) {1{Click here}}

API Reference #

See the API documentation for full details.

1
likes
0
points
192
downloads

Publisher

verified publisherpento.net

Weekly Downloads

A Flutter widget that renders text with interpolated tappable links using a simple template syntax.

Repository (GitHub)
View/report issues

Topics

#text #links #rich-text #url-launcher #widget

License

unknown (license)

Dependencies

flutter, url_launcher

More

Packages that depend on linked_text