Giter Club home page Giter Club logo

flutter_parsed_text_field's Introduction

A flutter package which lets you use styled @mentions and #hashtags or other similar mentions with suggestions in your TextField.

NOTE : This package is modified version of flutter_parsed_text_field original package ref : https://pub.dev/packages/flutter_parsed_text_field


New features added :

  • callback for detected query ie onQueryDetected (inorder to act on currently detected query)
  • limit the query by characters queryMaxChars
  • customize the size (height, width) of an overlay
  • provision to pick first suggestion from overlay, mandatorily

Table of contents

Installing

1. Depend on it

Add this to your package's pubspec.yaml file:

dependencies:
  flutter_parsed_text_field:
    git:
      url: https://github.com/nszenoti/flutter_parsed_text_field

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter pub get

3. Import it

Now in your Dart code, you can use:

import 'package:flutter_parsed_text_field/flutter_parsed_text_field.dart';

Usage

FlutterParsedTextField is a Stateful Widget that extends TextField.

FlutterParsedTextField(
    controller: controller.flutterParsedTextEditingController,
    suggestionMatches: suggestionMatches,
    disableSuggestionOverlay: disableSuggestionOverlay,
    suggestionLimit: suggestionLimit,
    suggestionPosition: suggestionPosition,
    matchers: [],
)

Configurable properties:

  • controller – extension of TextEditingController which styles your parsed text field
  • disableSuggestionOverlaytrue if you don't want the built-in suggestion list to appear; false otherwise.
  • suggestionLimit – number of suggestions to return
  • suggestionPosition – should the suggestion list appear above or below the text field
  • matchers - a list of Matcher which defines the triggers and suggestions
  • queryMaxChars - number of max characters allowed in detected query
  • overlayHeight - max height of an suggestion overlay box
  • overlayWidth - max-width of an suggestion overlay box

Callbacks:

  • suggestionMatches – returns a list of the suggestions that are matched
  • onQueryDetected - returns the query token detected (i.e after trigger character)

Matcher

Matcher<String>(
    trigger: "#",
    suggestions: ['BattleOfNewYork', 'InfinityGauntlet'],
    idProp: (hashtag) => hashtag,
    displayProp: (hashtag) => hashtag,
    style: const TextStyle(color: Colors.blue),
    stringify: (trigger, hashtag) => hashtag,
    alwaysHighlight: true,
    parse: (hashtagString) => hashtagString.substring(1),
)

Configurable properties:

  • trigger - single character to trigger suggestions
  • suggestions - list of suggestions
  • idProp - get the id of the suggestion
  • displayProp - get the display of the suggestion
  • style - TextStyle for matches
  • stringify - convert the suggestion into a parsable string
  • alwaysHighlight - always apply style even if there isn't a matching suggestion
  • parse - convert the parsable string into a suggestion
  • needToPickFirstSuggestion - true if need to pick first mention compulsorily from overlay suggestion box

Custom Suggestion List

If you dont want the built-in popup to appear, and instead display the suggestions elsewhere, you can! Check /example/lib/custom-suggestion-list.dart

License

MIT

flutter_parsed_text_field's People

Contributors

nszenoti avatar kulture-rob-snider avatar rsnider19 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.