Niku Text

Style property builder for building "Text".

Example usage:

As Widget

NikuText("As widget")
  ..color(Colors.blue)
  ..fontSize(21)

As Property

Text("As Property")
  .asNiku()
  ..color(Colors.blue)
  ..fontSize(21)

Availability

To use this widget, you can import from the following:

// All Widget
import 'package:niku/niku.dart';

// Extension
import 'package:niku/extension/widget.dart';

// Just widget
import 'package:niku/widget/text.dart';

niku

Switch to use parent property builder.

Example Usage:

NikuText()
  .niku();

Equivalent to

Niku(
  Text(),
);

apply

Apply predefined style properties to widget.

Example Usage:

final title = NikuText()
  ..color(Colors.red)
  ..fontSize(21);

NikuText()
  ..apply(title);

Equivalent to

Text()
  ..color(Colors.red)
  ..fontSize(21);

Equivalent to

Text(input);

style

Style Text using TextStyle

Example Usage:

NikuText()
  ..style(TextStyle(
    color: Colors.red,
  ));

NikuText()
  ..style(Theme.of(context).textTheme.headline1);

Equivalent to

Text(style: input);

theme

Style Text using TextTheme

Example Usage:

NikuText()
  ..theme(
    context,
    (theme) => theme.headline1,
  );

Equivalent to

Text(style: input2());

color

Set text's color.

Example Usage:

final title = NikuText()
  ..color(Colors.red);

NikuText()
  ..apply(title);

Equivalent to

Text(
  color: input,
)

backgroundColor

Set background color.

Example Usage:

NikuText()
  ..backgroundColor(Colors.red);

Equivalent to

Text(
  backgroundColor: input,
);

bg

Shorten syntax of backgroundColor

Set background color.

Example Usage:

NikuText()
  ..bg(Colors.red);

Equivalent to

Text(
  backgroundColor: input,
);

fontSize

Set font size.

Example Usage:

NikuText()
  ..fontSize(21);

Equivalent to

Text(
  fontSize: input,
);

fontWeight

Set font weight.

Example Usage:

NikuText()
  ..fontWeight(fontWeight.bold);

Equivalent to

Text(
  fontWeight: input,
);

bold

Shorten syntax of fontWeight

Set font weight using FontWeight.bold.

Example Usage:

NikuText()
  ..bold();

Equivalent to

Text(
  fontWeight: FontWeight.bold,
);

w100

Shorten syntax of fontWeight

Set font weight using FontWeight.w100.

Example Usage:

NikuText()
  ..w100();

Equivalent to

Text(
  fontWeight: FontWeight.w100,
);

w200

Shorten syntax of fontWeight

Set font weight using FontWeight.w200.

Example Usage:

NikuText()
  ..w200();

Equivalent to

Text(
  fontWeight: FontWeight.w200,
);

w300

Shorten syntax of fontWeight

Set font weight using FontWeight.w300.

Example Usage:

NikuText()
  ..w300();

Equivalent to

Text(
  fontWeight: FontWeight.w300,
);

w400

Shorten syntax of fontWeight

Set font weight using FontWeight.w400.

Example Usage:

NikuText()
  ..w400();

Equivalent to

Text(
  fontWeight: FontWeight.w400,
);

w500

Shorten syntax of fontWeight

Set font weight using FontWeight.w500.

Example Usage:

NikuText()
  ..w500();

Equivalent to

Text(
  fontWeight: FontWeight.w500,
);

w600

Shorten syntax of fontWeight

Set font weight using FontWeight.w600.

Example Usage:

NikuText()
  ..w600();

Equivalent to

Text(
  fontWeight: FontWeight.w600,
);

w700

Shorten syntax of fontWeight

Set font weight using FontWeight.w700.

Example Usage:

NikuText()
  ..w700();

Equivalent to

Text(
  fontWeight: FontWeight.w700,
);

w800

Shorten syntax of fontWeight

Set font weight using FontWeight.w800.

Example Usage:

NikuText()
  ..w800();

Equivalent to

Text(
  fontWeight: FontWeight.w800,
);

w900

Shorten syntax of fontWeight

Set font weight using FontWeight.w900.

Example Usage:

NikuText()
  ..w900();

Equivalent to

Text(
  fontWeight: FontWeight.w900,
);

fontStyle

Set font style.

Example Usage:

NikuText()
  ..fontStyle(FontStyle.italic);

Equivalent to

Text(
  fontStyle: input,
);

italic

Shorten syntax of fontStyle

Set font weight using FontStyle.italic.

Example Usage:

NikuText()
  ..italic();

Equivalent to

Text(
  fontStyle: FontStyle.italic,
);

letterSpacing

Set letter spacing.

Example Usage:

NikuText()
  ..letterSpacing(2);

Equivalent to

Text(
  letterSpacing: input,
);

wordSpacing

Set word spacing.

Example Usage:

NikuText()
  ..wordSpacing(2);

Equivalent to

Text(
  wordSpacing: input,
);

height

Set height.

Example Usage:

NikuText()
  ..letterSpacing(2);

Equivalent to

Text(
  letterSpacing: input,
);

foreground

The paint drawn as a foreground for the text.

Example Usage:

final paint = Paint()..color = Colors.blue;

NikuText()
  ..foreground(paint);

Equivalent to

Text(
  foreground: input,
);

background

The paint drawn as a foreground for the text.

Example Usage:

final paint = Paint()..color = Colors.blue;

NikuText()
  ..background(paint);

Equivalent to

Text(
  background: input,
);

shadows

Collection of text's shadow.

Example Usage:

NikuText()
  ..shadows([
    Shadow(
      offset: Offset(0, 4),
      blurRadius: 8,
      color: Colors.black.withOpacity(.1),
    )
  ]);

Equivalent to

Text(
  shadows: input,
);

fontFeature

A feature tag and value that affect the selection of glyphs in a font.

Example Usage:

NikuText()
  ..fontFeatures([
    FontFeature.enable('smcp'),
  ]);

Equivalent to

Text(
  fontFeatures: input,
);

textDecoration

Add TextDecoration.

Example Usage:

NikuText()
  ..textDecoration(TextDecoration.underline);

Equivalent to

Text(
  textDecoration: input,
);

textDecorationColor

Set Color of text decoration

Example Usage:

NikuText()
  ..textDecorationColor(Colors.blue);

Equivalent to

Text(
  textDecorationColor: input,
);

textDecorationThickness

Set thickness of text decoration

Example Usage:

NikuText()
  ..textDecorationThickness(2);

Equivalent to

Text(
  textDecorationThickness: input,
);

fontFamily

Set font of text.

Example Usage:

NikuText()
  ..fontFamily('Helvetica Neue');

Equivalent to

Text(
  fontFamily: input,
);

fontFamilyFallback

Set font fallback of text if fontFamily is missing.

Example Usage:

NikuText()
  ..fontFamilyFallback([
    'Roboto',
    'Segoe UI',
    'Open Sans',
  ]);

Equivalent to

Text(
  fontFamilyFallback: input,
);

textBaseline

The common baseline that should be aligned between this text span and its parent text span, or, for the root text spans, with the line box.

Example Usage:

NikuText()
  ..textBaseline(Textbaseline.alphabetic);

Equivalent to

Text(
  textBaseline: input,
);

alphabetic

Shorten syntax of textBaseline

The common baseline that should be aligned between this text span and its parent text span, or, for the root text spans, with the line box.

Using Textbaseline.alphabetic

Example Usage:

NikuText()
  ..alphabetic();

Equivalent to

Text(
  textBaseline: Textbaseline.alphabetic,
);

ideographic

Shorten syntax of textBaseline

The common baseline that should be aligned between this text span and its parent text span, or, for the root text spans, with the line box.

Using Textbaseline.alphabetic

Example Usage:

NikuText()
  ..ideographic();

Equivalent to

Text(
  textBaseline: Textbaseline.ideographic,
);

align

The common baseline that should be aligned between this text span and its parent text span, or, for the root text spans, with the line box.

Example Usage:

NikuText()
  ..align(TextAlign.center);

Equivalent to

Text(
  textAlign: input,
);

alignLeft

Shorten syntax of textAlign

The common baseline that should be aligned between this text span and its parent text span, or, for the root text spans, with the line box.

Using TextAlign.left.

Example Usage:

NikuText()
  ..alignLeft();

Equivalent to

Text(
  textAlign: TextAlign.left,
);

left

Shorten syntax of textAlign

The common baseline that should be aligned between this text span and its parent text span, or, for the root text spans, with the line box.

Using TextAlign.left.

Example Usage:

NikuText()
  ..left();

Equivalent to

Text(
  textAlign: TextAlign.left,
);

alignCenter

Shorten syntax of textAlign

The common baseline that should be aligned between this text span and its parent text span, or, for the root text spans, with the line box.

Using TextAlign.center.

Example Usage:

NikuText()
  ..alignCenter();

Equivalent to

Text(
  textAlign: TextAlign.center,
);

center

Shorten syntax of textAlign

The common baseline that should be aligned between this text span and its parent text span, or, for the root text spans, with the line box.

Using TextAlign.center.

Example Usage:

NikuText()
  ..center();

Equivalent to

Text(
  textAlign: TextAlign.center,
);

alignRight

Shorten syntax of textAlign

The common baseline that should be aligned between this text span and its parent text span, or, for the root text spans, with the line box.

Using TextAlign.right.

Example Usage:

NikuText()
  ..alignRight();

Equivalent to

Text(
  textAlign: TextAlign.right,
);
Shorten syntax of textAlign

The common baseline that should be aligned between this text span and its parent text span, or, for the root text spans, with the line box.

Using TextAlign.right.

Example Usage:

NikuText()
  ..right();

Equivalent to

Text(
  textAlign: TextAlign.right,
);

alignStart

Shorten syntax of textAlign

The common baseline that should be aligned between this text span and its parent text span, or, for the root text spans, with the line box.

Using TextAlign.start.

Example Usage:

NikuText()
  ..alignStart();

Equivalent to

Text(
  textAlign: TextAlign.start,
);

start

Shorten syntax of textAlign

The common baseline that should be aligned between this text span and its parent text span, or, for the root text spans, with the line box.

Using TextAlign.start.

Example Usage:

NikuText()
  ..start();

Equivalent to

Text(
  textAlign: TextAlign.start,
);

alignEnd

Shorten syntax of textAlign

The common baseline that should be aligned between this text span and its parent text span, or, for the root text spans, with the line box.

Using TextAlign.end.

Example Usage:

NikuText()
  ..alignEnd();

Equivalent to

Text(
  textAlign: TextAlign.end,
);

end

Shorten syntax of textAlign

The common baseline that should be aligned between this text span and its parent text span, or, for the root text spans, with the line box.

Using TextAlign.end.

Example Usage:

NikuText()
  ..end();

Equivalent to

Text(
  textAlign: TextAlign.end,
);

alignJustify

Shorten syntax of textAlign

The common baseline that should be aligned between this text span and its parent text span, or, for the root text spans, with the line box.

Using TextAlign.justify.

Example Usage:

NikuText()
  ..alignJustify();

Equivalent to

Text(
  textAlign: TextAlign.justify,
);

justify

Shorten syntax of textAlign

The common baseline that should be aligned between this text span and its parent text span, or, for the root text spans, with the line box.

Using TextAlign.justify.

Example Usage:

NikuText()
  ..justify();

Equivalent to

Text(
  textAlign: TextAlign.justify,
);

textDirection

Set whether text is left-to-right or right-to-left direction.

Example Usage:

NikuText()
  ..textDirection(TextDirection.ltr);

Equivalent to

Text(
  textDirection: input,
);

ltr

Shorten syntax of textDirection

Set whether text is left-to-right or right-to-left direction.

Using TextDirection.ltr.

Example Usage:

NikuText()
  ..ltr();

Equivalent to

Text(
  textDirection: TextDirection.ltr,
);

rtl

Shorten syntax of textDirection

Set whether text is left-to-right or right-to-left direction.

Using TextDirection.rtl.

Example Usage:

NikuText()
  ..rtl();

Equivalent to

Text(
  textDirection: TextDirection.rtl,
);

locale

Whether the text should break at soft line breaks.

Example Usage:

NikuText()
  ..softWrap(true);

Equivalent to

Text(
  softWrap: input,
);

overflow

How visual overflow should be handled.

Example Usage:

NikuText()
  ..overflow(TextOverflow.ellipsis);

Equivalent to

Text(
  overflow: input,
);

textScaleFactor

The number of font pixels for each logical pixel.

Example Usage:

NikuText()
  ..textScaleFactor(2);

Equivalent to

Text(
  textScaleFactor: input,
);

maxLines

Set max line for text.

Example Usage:

NikuText()
  ..maxLines(3);

Equivalent to

Text(
  maxLines: input,
);

semanticsLabel

Semantics label for text, good for screen reader.

Example Usage:

NikuText()
  ..semanticsLabel("Hello World");

Equivalent to

Text(
  semanticsLabel: input,
);

label

Shorten syntax of semanticsLabel

Semantics label for text, good for screen reader.

Example Usage:

NikuText()
  ..label("Hello World");

Equivalent to

Text(
  semanticsLabel: input,
);

textWidthBasis

Defines how to measure the width of the rendered text.

Example Usage:

NikuText()
  ..textWidthBasis(textWidthBasis.parent);

Equivalent to

Text(
  textWidthBasis: input,
);

textHeightBehavior

Defines how the paragraph will apply [TextStyle.height] to the ascent of the first line and descent of the last line.

Example Usage:

NikuText()
  ..textHeightBehavior(
    textHeightBehavior.fromEncoded(2),
  );

Equivalent to

Text(
  textWidthBasis: input,
);