free_form_text 0.4.4 copy "free_form_text: ^0.4.4" to clipboard
free_form_text: ^0.4.4 copied to clipboard

Styled, free form text painted to a Canvas at arbitrary angles and along a path

free_form_text #

An API for painting styled text to a Canvas.

Text is styled with the TextStyle class and can be painted at any arbitrary angle as well as along a defined path. The API should be useful for applications that require angled and free form text such as games or GIS mapping.

Features #

  • Style the text with TextStyle.
  • Paint text at arbitrary angles.
  • Paint text along a specified path defined as a List of Offset.

Getting started #

To use this plugin, add free_form_text as a dependency in your pubspec.yaml file. For example:

dependencies:
  free_form_text: '^0.4.4'

Usage #

To apply the API, import package:free_form_text/free_form_text.dart, create a Future<FreeFormText> and use it in a FutureBuilder that includes a CustomPaint widget as illustrated below. The actual painting is done in a CustomPainter.

Create a FreeFormText object:

    FreeFormText text = FreeFormText(
        label: 'Lorem ipsum dolor sit amet.',
        context: context,
        style: const TextStyle(
            fontSize: 16,
            color: Colors.black,
            wordSpacing: 2.0,
            letterSpacing: 0.5,
            fontWeight: FontWeight.bold));
    Future<FreeFormText> textFuture = text.layout();

Then paint it in a CustomPainter:

class ExampleTextPainter extends CustomPainter {
  FreeFormText text;
  ExampleTextPainter(this.text);
  @override
  void paint(Canvas canvas, Size size) {
    var painter = FreeFormTextPainter(canvas);
    painter.paintText(
        text: text, offset: const Offset(50.0, 200.0), angle: 30.0);
  }
  @override
  bool shouldRepaint(covariant CustomPainter oldDelegate) {
    return false;
  }
}
0
likes
140
pub points
0%
popularity

Publisher

verified publisherredfishresearch.com

Styled, free form text painted to a Canvas at arbitrary angles and along a path

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (LICENSE)

Dependencies

flutter, image, path_provider

More

Packages that depend on free_form_text