Giter VIP home page Giter VIP logo

hashtagable's Introduction

hashtagable

test pub package License: MIT

Widgets and functions to implement hashTag decorated text.

Detects the words start with # like a Twitter.

RPReplay_Final1599932903

Usage

  • As TextField

You can use HashTagTextField to decorate input text.

    HashTagTextField(
    decoratedStyle: TextStyle(fontSize: 14, color: Colors.blue),
    basicStyle: TextStyle(fontSize: 14, color: Colors.black),
    ),

decoratedStyle is the textStyle of tagged text. basicStyle is for untagged text.

Other arguments are basically same as those of material TextField

  • As ReadOnlyText

If you want to decorate the text only to display, HashTagText will help you.

    HashTagText(
        text: "#Welcome to #hashtagable \n This is #ReadOnlyText",
        decoratedStyle: TextStyle(fontSize: 22,color:Colors.red),
        basicStyle: TextStyle(fontSize: 22,color:Colors.black),
        onTap: (text) {
          print(text);
        },
    )

The argument onTap(String) is called when user tapped a hashTag.

You can add some actions in this callback with the tapped hashTag.

Customize with useful functions

  • Check if the text has hashTags
   print(hasHashtags("Hello #World")); 
   // true
   
   print(hasHashtags("Hello World"));
   // false
   
  • Extract hashTags from text
   final List<String> hashTags = extractHashTags("#Hello World #Flutter Dart #Thank you");
   // ["#Hello", "#Flutter", "#Thank"]

Tips

  • DetectableTextField is published as a refinement of this package. hashtagale forces you to use hashtag, but this one allows you to detect anything you want.

  • If you also want to decorate At sign, you can do that by adding the argument decorateAtSign: true.

    HashTagText(
        text: "#Hello World @flutter_developers",
        decoratedStyle: TextStyle(fontSize: 14,color:Colors.red),
        basicStyle: TextStyle(fontSize: 14,color:Colors.black),
        onTap: (text) {
          print(text);
        },
        decorateAtSign: true,
    )

Then HashTagText and HashtagTextField come to decorate the words start with # or @.

  • The decoration rules are almost same as twitter. It does not decorate the tags which contain emoji or symbol. It needs space before # (or @) to decorate.

  • Supported Languages are English, Japanese, Korean, Spanish, Arabic, Thai, Norwegian and German.

If you have any requests or questions, please feel free to ask on github.


Contributors: Santa Takahashi, Matheus Perez, Marcel Schneider, Ho Kim, Burak

hashtagable's People

Contributors

santa112358 avatar matheusperez avatar hokim98 avatar buraktabn avatar schnmar avatar erafraw7 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.