selectable_autolink_text 1.0.0+1 copy "selectable_autolink_text: ^1.0.0+1" to clipboard
selectable_autolink_text: ^1.0.0+1 copied to clipboard

outdated

Generate inline links that can be selected, clicked and long pressed in text for Flutter.

Selectable Autolink Text #

Generate inline links that can be selected, clicked and long pressed in text for Flutter

Example

Install #

Install by adding this package to your pubspec.yaml:

dependencies:
  flutter_selectable_autolink_text: ^1.0.0+1

Usage #

Basic #

import 'package:selectable_autolink_text/selectable_autolink_text.dart';

class MyHomePage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return SelectableAutoLinkText(
      'Basic https://flutter.dev',
      linkStyle: TextStyle(color: Colors.blueAccent),
      onTap: (url) => print('🍅Tap: $url'),
      onLongPress: (url) => print('🍕LongPress: $url'),
    );    
  }
}

Advanced #

import 'package:selectable_autolink_text/selectable_autolink_text.dart';
import 'package:share/share.dart';
import 'package:url_launcher/url_launcher.dart';

class MyHomePage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return SelectableAutoLinkText(
      '''
Selectable Autolink Text https://github.com/housmart/flutter_selectable_autolink_text
for Flutter https://flutter.dev
tel:012-3456-7890
tel +81-12-3456-7890
email mail@example.com''',
      style: TextStyle(color: Colors.black87),
      linkStyle: TextStyle(color: Colors.purpleAccent),
      onTransformDisplayLink: AutoLinkUtils.shrinkUrl,
      onTap: (url) async {
        print('🌶Tap: $url');
        if (await canLaunch(url)) {
          launch(url, forceSafariVC: false);
        }
      },
      onLongPress: (url) {
        print('🍔LongPress: $url');
        Share.share(url);
      },
    );
  }
}

Customized #

import 'package:selectable_autolink_text/selectable_autolink_text.dart';

class MyHomePage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return SelectableAutoLinkText(
      'Custom link @screen_name. Hello #hash_tag! Like https://twitter.com.',
      style: TextStyle(color: Colors.brown),
      linkStyle: TextStyle(color: Colors.orangeAccent),
      linkRegExpPattern: '(@[\\w]+|#[\\w]+|${AutoLinkUtils.urlRegExpPattern})',
      onTransformDisplayLink: AutoLinkUtils.shrinkUrl,
      onTap: (url) => print('🍒Tap: $url'),
      onLongPress: (url) => print('🍩LongPress: $url'),
      onDebugMatch: (match) =>
          print('DebugMatch:[${match.start}-${match.end}]`${match.group(0)}`'),
    );
  }
}
79
likes
0
pub points
93%
popularity

Publisher

verified publishermiyake.id

Generate inline links that can be selected, clicked and long pressed in text for Flutter.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on selectable_autolink_text