binkap_parsely 0.0.2 copy "binkap_parsely: ^0.0.2" to clipboard
binkap_parsely: ^0.0.2 copied to clipboard

A Flutter package for parsing links, emails, @mentions, hashtags, and phone numbers from text. Mask extracted elements with custom patterns and add tappable click behavior for seamless interactions

Parsely #

Parsely is a powerful tool for text parsing and masking in your Flutter applications. It allows you to extract various entities such as links, email addresses, @mentions, hashtags, and phone numbers from text. Additionally, Parsely offers customizable masking functionality to obscure sensitive information while keeping it in the desired format and ensuring it's still clickable.

Key Features #

  • Entity Parsing: Effortlessly parse links, email addresses, @mentions, hashtags, and phone numbers embedded within text strings.
  • Customizable Masks: Define custom masks to obscure sensitive information like email addresses or phone numbers while retaining their format.
  • Clickable Entities: Automatically convert parsed entities (links, emails, phone numbers, etc.) into clickable elements that users can interact with.
  • Flexible Integration: Easily integrate the parsing and masking functionality into your Flutter applications with minimal setup.
  • Performance Optimized: Designed to handle large volumes of text efficiently while ensuring smooth user experience.
  • Cross-Platform Support: Fully compatible with all platforms supported by Flutter, including iOS, Android, Web, and Desktop.

Use Cases #

  • Social Media Apps: Enhance engagement by making @mentions and hashtags clickable in posts or comments.
  • Messaging Platforms: Improve UX by automatically parsing and masking phone numbers and email addresses in conversations.
  • E-commerce Apps: Protect user privacy by masking sensitive details (like emails or phone numbers) while allowing clickable product links.
  • Content Sharing Apps: Simplify content sharing by parsing and masking URLs within descriptions or captions.

Installation #

To use Parsely in your Flutter project, add the following dependency to your pubspec.yaml:

dependencies:
  binkap_parsely: <latest_version>
  • Alternatively, run this command in your terminal:

#

flutter pub add binkap_parsely

Usage #

To use this package, add binkap_parsely as a dependency in your pubspec.yaml file.

to /example folder.

import 'package:binkap_parsely/binkap_parsely.dart';

Parsely(
  text:
      'Visit me at https://binkap.com, or you could send me an email at rea.desert.tiger@gmail.com. Supposedly you prefer calls? Reach me at +2348068989116 or simply use #binkap on Twitter.',
  textAlign: TextAlign.center,
  options: ParselyOptions(  // Optional configuration
    parseMentionTag: true, // Default: true
    humanize: true,        // Default: true
    parsePhone: true,      // Default: true
    parseHashTag: true,    // Default: true
    parseEmail: true,      // Default: true
    parseLink: true,       // Default: true
  ),
  mask: ParselyMask(  // Optional masking configuration
    matches: [
      '+2348068989116',  // Match specific values for masking
    ],
    masks: [
      'My Contact',  // Mask text
    ],
  ),
  style: const TextStyle(  // Styling for unmatched text
    color: Colors.white,
    fontSize: 20,
    fontWeight: FontWeight.bold,
    fontFamily: 'DancingScript',
  ),
  parsedStyle: const TextStyle(  // Styling for matched text
    color: Color.fromARGB(255, 33, 243, 86),
    fontSize: 20,
    fontWeight: FontWeight.bold,
    fontFamily: 'DancingScript',
  ),
  onTap: (element) {  // Callback for matched element clicks
    switch (element.type) {
      case ParselyType.link:
        print('Clicked link: ${element.parsed}');
        break;
      case ParselyType.email:
        print('Clicked email: ${element.parsed}');
        break;
      case ParselyType.phone:
        print('Clicked phone number: ${element.parsed}');
        break;
      case ParselyType.hashTag:
        print('Clicked hashtag: ${element.parsed}');
        break;
      case ParselyType.mentionTag:
        print('Clicked @mention: ${element.parsed}');
        break;
      default:
        print('Unknown element clicked');
    }
  },
);

Dictionary #

Parameters #

ParselyElement #

This class represents the parsed element. It contains two properties:

Parameter Type Description
type ParselyType The type of the parsed entity (link, email, phone, etc.)
parsed String The parsed text that was identified (e.g., URL, email, etc.)

ParselyOptions #

Options to control how Parsely parses the text. These are all optional and come with default values.

Parameter Type Description Default
parseMentionTag bool Enable parsing of @mentions true
humanize bool Whether to humanize the parsed text (e.g., formatting) true
parsePhone bool Enable parsing of phone numbers true
parseHashTag bool Enable parsing of hashtags true
parseEmail bool Enable parsing of email addresses true
parseLink bool Enable parsing of URLs true

ParselyMask #

Allows you to define specific masks for parsed entities. The matches parameter defines which entities are to be masked, and the masks parameter defines the text that will replace the matched text.

Parameter Type Description
matches List<String> A list of strings that should be masked.
masks List<String> A list of masks that replace the matched text.

Additional Information #

  • Performance Optimized: Parsely has been engineered to handle large blocks of text efficiently, ensuring smooth interactions even with extensive data inputs.
  • Cross-platform Compatibility: Works seamlessly across all platforms supported by Flutter, including Android, iOS, Web, and Desktop.

Contributions #

Feel free to contribute to Parsely! Whether it’s fixing bugs, suggesting improvements, or adding new features, your contributions are welcome. Please refer to the contributing guide for more information.

License #

This package is licensed under the MIT LICENSE.

2
likes
130
points
64
downloads

Publisher

verified publisherbinkap.com

Weekly Downloads

A Flutter package for parsing links, emails, @mentions, hashtags, and phone numbers from text. Mask extracted elements with custom patterns and add tappable click behavior for seamless interactions

Homepage

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on binkap_parsely