Giter Club home page Giter Club logo

fxf's Introduction

fxf

A Flutter package that converts plain text (txt) into Rich Text using style commands.

Features

Change a text's boldness in the text itself.

'''
Hello *(5)World!
'''

hello_world Change many styles at the same time.

'''
Hello *(5)~(0xffff0000)World!*(d)~(d)
Hello *(5)~(0xff00ff00)World!*(d)~(d)
Hello *(5)~(0xff0000ff)World!*(d)~(d)
'''

hello_world_color Create links (with the help of url_launcher).

'''
Search #(https://www.google.com/)google#(d) for more information.
'''

link

Usage

Minimal example for getting started.

import 'package:fxf/fxf.dart' as fxf;

class MyWidget extends StatelessWidget {
  ...
  Widget build(BuildContext context) {
    return Center(
      child: fxf.Text("Hello *(5)World!"),
    );
  }
}

Example for creating links using url_launcher.

import 'package:fxf/fxf.dart' as fxf;
import 'package:url_launcher/url_launcher.dart';

class MyWidget extends StatelessWidget {
  ...
  Widget build(BuildContext context) {
    return Center(
      child: fxf.Text(
        "Search #(https://www.google.com/)google#(d) for more information.",
        onLinkTap: (link) {
          launchUrl(Uri.parse(link));
        },
      ),
    );
  }
}

Style Commands

* - bold
! - underline
^ - size
~ - color
` - italics
@ - font
# - link

Bold - *

*(weight: int)

weight: an integer clipped between [-3 - 5] and corresponds to FontWeight. 0 means normal font weight. 5 means FontWeight.w900. -3 means FontWeight.w100.

Underline - !

!(lineType: int, lineStyle: int, color: int)

lineType: an integer clipped between [0 - 3] and corresponds to TextDecoration:

  1. TextDecoration.none
  2. TextDecoration.underline
  3. TextDecoration.overline
  4. TextDecoration.lineThrough

lineStyle: an integer clipped between [0 - 4] and corresponds to TextDecorationStyle.

color: an integer clipped between [0x00000000 - 0xffffffff] and corresponds to TextStyle.decorationColor.

Size - ^

^(size: double)

size: a double clipped between [0 - infinity] and corresponds to TextStyle.fontSize.

Color - ~

~(color: int)

color: an integer clipped between [0x00000000 - 0xffffffff] and corresponds to TextStyle.color.

Italics - `

`(isOn: int)

isOn: an integer clipped between [0 - 1] and corresponds to FontStyle.

Font - @

@(font: str)

font: a string that corresponds to TextStyle.fontFamily.

Link - #

#(link: str, styleChange: int, color: int, isUnderline: int)

link: a string that holds the link.

styleChange: an integer clipped between [0 - 1]. If 0, the link text will not change it's style when hovered over. Otherwise, change link text style.

color: an integer clipped between [0x00000000 - 0xffffffff] and corresponds to TextStyle.color. This color will only appear when hovered over or clicked.

isUnderline: an integer clipped between [0 - 1]. If 0, the link will not be underlined. Otherwise, underline.

Default values - "d"

When style commands have as input "d" as in *(d), it defers to the default TextStyle for the corresponding style command. For example, if the default font weight is normal, then *(d) is actually *(0). If the default font weight is bold, then *(d) is *(3).

The same can be said for style commands with more than one parameter like underline. Not every parameter for underline needs to be specified in the style command. Ex: !(1) underlines the text, but keeps the default lineStyle and color alone.

For link commands, when #(d) is used, it's to end a link area (see example above).

Installation

In your pubspec.yaml, add to your dependencies:

dependencies:
    ...
    fxf:
        git:
            url: https://github.com/getrod/fxf.git

fxf's People

Contributors

getrod avatar

Watchers

 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.