Arc Text Widget for Flutter

Overview

Flutter Arc Text

Renders text along the arc. See demo.

The story behind the plugin is here.

Basic usage

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) => ArcText(
        radius: 100,
        text: 'Hello, Flutter!',
        textStyle: TextStyle(fontSize: 18, color: Colors.black),
        startAngle: -pi / 2,
        startAngleAlignment: StartAngleAlignment.start,
        placement: Placement.outside,
        direction: Direction.clockwise
      );
}

Example

See example project.

Comments
  • anti-clockwise, static function, length computation

    anti-clockwise, static function, length computation

    Very useful code, thank you!

    I'm currently porting an Android/java app to flutter; I have some needs/suggestions, that I will have to implement and may integrate into this project (if you're OK with that):

    1. being able to write text anti-clockwise
    2. calling the code from any CustomPainter (which may mean moving the code into a static function or tool class)
    3. adding some length() tools - I have no control on the text, which means I need to check if it fits in this circle (if not, I use a smaller font size for instance)
    opened by monsieurtanuki 22
  • New feature for text stretching

    New feature for text stretching

    I've just developed a very useful feature: a double interLetterSpacing = 0 parameter in the ArcTextPainter constructor.

    The idea behind that is:

    1. I've got a text to display around a circle
    2. I compute the "final angle", let's say it's pi
    3. If I display the text as is, it's going to be displayed on a pi angle, fair enough
    4. But I would like the text to stretch to the whole 2*pi angle
    5. The idea is to rotate an extra angle for each letter - hence the extra parameter in the constructor

    Computing the extra angle is my own business so far (something like (2*pi - getFinalAngle()) / text.length), though it could also be included in the library (like a bool autoStretch = false parameter in the constructor). But the thing absolutely needed is the support of this double interLetterSpacing = 0 parameter in the ArcTextPainter constructor.

    What do you think about that?

    opened by monsieurtanuki 9
  • feat!: Add PainterDelegate

    feat!: Add PainterDelegate

    Added PainterDelegate that can be used to customize the way the text will be drawn.

    With the delegate you can control when the text will be drawn with painter.paint(canvas, size), so you can add a decoration before and after the text:

    Screenshot 2021-04-11 at 13 11 41

    This layout can be achieved with the following delegate:

    void delegate(Canvas canvas, Size size, ArcTextPainter painter) {
      final rect = Rect.fromLTWH(0, 0, size.width, size.height);
    
      canvas.drawArc(
        rect,
        painter.startAngle,
        painter.sweepAngle,
        false,
        _decorationPaint,
      );
    
      painter.paint(canvas, size);
    
      canvas.drawArc(
        rect,
        painter.finalAngle + radians(10),
        2 * pi - painter.sweepAngle - radians(20),
        false,
        _backgroundPaint,
      );
    }
    

    It introduces some breaking changes:

    • getFinalAngle is changed to sweepAngle getter, as it actually returns the total angle, not the absolute final angle.
    • paint now accepts Size instead of Offset and offset is always in the center of this Size rectangle. It makes delegate simpler.

    There's one thing I don't like here: using drawArc you still have to add -pi / 2 for the angles, as drawArc 0 angle is at point (1; 0). For me, 0 angle should start at point (0; 1), so it was implemented like this in the library. I'm not sure whether it makes sense to introduce another breaking change and make library's 0 angle aligned with drawArc.

    opened by ookami-kb 7
  • New feature: `Placement`

    New feature: `Placement` "middle"

    For the record, during the development of my app I've just found out that I was better off with a new Placement value: middle. And I also use the following parameters in order to have a very good top/bottom match with the texts on both Direction at the same time:

    TextStyle(
      textBaseline: TextBaseline.ideographic,
      height: 1,
    )
    

    That's not 100% related, but I've also built classes in order to have flutter_arc_text work not only on Canvas, but also on html.CanvasRenderingContext2D. Not sure if many people would be interested by that.

    opened by monsieurtanuki 3
  • Decoration support

    Decoration support

    I would like to have a background container along with the arc text which have rounded corners. And with a gradient bg color. For the time being it seems impossible to do.

    However this is very important to use over images since image might be same color with the text so we need something behind the text.

    What do you think @ookami-kb @monsieurtanuki ?

    opened by aytunch 2
  • Support null safety

    Support null safety

    The library 'package:flutter_arc_text/flutter_arc_text.dart' is legacy, and should not be imported into a null safe library.
    Try migrating the imported library.
    
    Error: This project cannot run with sound null safety, because one or more project dependencies do not
    support null safety:
    
    - flutter_arc_text
    
    dependencies:
      flutter_arc_text: ^0.3.2
    
    opened by md84419 2
  • adding StartAngleAlignment

    adding StartAngleAlignment

    Trying to add some texts to an arc, I came across your code. I wanted the text to be in the center of the arc though, so I added startAngleAlignment attribute which can be .start, .center or .end. By default, it'll be .start so it won't break the code.

    Cheers!

    opened by HosseinYousefi 2
  • quastion

    quastion

    I am using flutter_map library to draw polylines, everything working as excepted until I want to draw some text alongside the polyline. after several hours of searching over google, StackOverflow, etc.., I could not find a way to let the text rotate with the polyline, then I find your article on medium I find it a good start point, I tried to draw without rotation equation, just plain text here are the results : Screen Shot 2021-10-20 at 8 35 40 AM

    Now I just need a way to let the text rotate with the polyline. I appreciate your work.

    opened by mohammedX6 1
  • Feature: improved emoji support

    Feature: improved emoji support

    The current rendering based on runes has issues when rendering complex emojis (composed out of multiple unicode chars, e.g. 👨🏻‍💻 breaks down to several runes 👨 🏻 💻, see emojipedia )

    When using grapheme clusters (provided by characters package) this can be solved since they split text in visible / user-perceived characters.

    Note: 8cf0f1d is based on the previous version of arc_text (pre null-safety) for a potential back-port

    opened by flo80 1
  • feature/clockwise

    feature/clockwise

    I added a clockwise parameter for the direction of the text.

    I simplified the code in the process: I had trouble understanding the concept of canvas rotation when not centered on the canvas center. Now there's only an initial canvas translation to its center, and then multiple rotations (all based on the canvas center).

    opened by monsieurtanuki 1
Owner
Kirill Bubochkin
Mobile/Web developer. Head of Applications at Mews.
Kirill Bubochkin
A Flutter package to parse text and make them into linkified text widget

?? Flutter Parsed text A Flutter package to parse text and extract parts using predefined types like url, phone and email and also supports Regex. Usa

Fayeed Pawaskar 213 Dec 27, 2022
Rich Text renderer that parses Contentful Rich Text JSON object and returns a renderable Flutter widget

Contentful Rich Text Renderer for Flutter Rich Text renderer that parses Contentful Rich Text field JSON output and produces a Flutter Widget tree tha

Kumanu 45 Nov 10, 2022
Flutter widget that automatically resizes text to fit perfectly within its bounds.

Flutter widget that automatically resizes text to fit perfectly within its bounds. Show some ❤️ and star the repo to support the project Resources: Do

Simon Leier 1.8k Jan 3, 2023
A masked text for Flutter.

flutter_masked_text Masked text input for flutter. Alert Hi guys! Unfortunately, I'm not developing mobile anymore. This repo will not receive updates

Ben-hur Santos Ott 264 Dec 21, 2022
Soft and gentle rich text editing for Flutter applications.

About Zefyr Soft and gentle rich text editing for Flutter applications. You are viewing early dev preview version of this package which is no longer a

Memspace 2.2k Jan 8, 2023
A simple Flutter package that makes turning a FAB into a text field easy.

flutter_text_field_fab A simple Flutter widget that makes turning a FAB into a text field easy.

Haefele Software 4 Jan 18, 2022
Soft and gentle rich text editing for Flutter applications

Soft and gentle rich text editing for Flutter applications. Zefyrka is a fork of Zefyr package with the following improvements: support Flutter 2.0 op

null 85 Dec 21, 2022
Text Editor in Flutter for Android and iOS to help free write WYSIWYG HTML code

Flutter Summernote Text Editor in Flutter for Android and iOS to help free write WYSIWYG HTML code based on Summernote 0.8.18 javascript wrapper. NOTI

Chandra Abdul Fattah 41 Sep 12, 2022
A Tricky Solution for Implementing Inline-Image-In-Text Feature in Flutter.

A Tricky Solution for Implementing Inline-Image-In-Text Feature in Flutter.

Bytedance Inc. 646 Dec 29, 2022
A customizable code text field supporting syntax highlighting

CodeField A customizable code text field supporting syntax highlighting Live demo A live demo showcasing a few language / themes combinaisons Showcase

Bertrand 162 Dec 23, 2022
Flutter textfield validation lets you validate different textform fields in your Flutter app

Flutter textfield validation lets you validate different textform fields in your Flutter app

World-Package 2 Sep 15, 2022
A markdown renderer for Flutter.

Flutter Markdown A markdown renderer for Flutter. It supports the original format, but no inline HTML. Overview The flutter_markdown package renders M

Flutter 828 Aug 12, 2021
A Flutter Package to render Mathematics, Physics and Chemistry Equations based on LaTeX

flutter_tex Contents About Demo Video Screenshots How to use? Android iOS Web Examples Quick Example TeXView Document TeXView Markdown TeXView Quiz Te

Shahzad Akram 219 Jan 5, 2023
flutter 中文排版,支持分页上下对齐 两端对齐 翻页动画

text_composition flutter 中文排版 分页 上下对齐 两端对齐 多栏布局 弃用richText,使用Canvas,精确定位绘图位置,消除字体对排版影响 视频与截图 demo https://github.com/mabDc/text_composition/releases/t

西红柿大芝麻 50 Nov 3, 2022
Flutter Tutorial - PDF Viewer - Asset, File, Network & Firebase

Flutter Tutorial - PDF Viewer - Asset, File, Network & Firebase Use the Flutter PDF Viewer to download PDF documents and display them within your Flut

Johannes Milke 36 Dec 9, 2022
Create an AutoComplete TextField to search JSON data based on suggestions in Flutter.

Flutter Tutorial - AutoComplete TextField & AutoComplete Search Create an AutoComplete TextField to search JSON data based on suggestions in Flutter.

Johannes Milke 32 Oct 23, 2022
Flutter phone number input

phone_form_field Flutter phone input integrated with flutter internationalization Features Totally cross platform, this is a dart only package / depen

cedvdb 38 Dec 31, 2022
A low code editor with the full power of flutter.

flutter_blossom ?? Low code editor with the full power of flutter. Think in flutter, watch your ideas come to life, plan ahead and let your creativity

Flutter Blossom 0 Dec 2, 2021
A Flutter package provides some implementations of TextInputFormatter that format input with pre-defined patterns

A Flutter package provides some implementations of TextInputFormatter that format input with pre-defined patterns

HungHD 192 Dec 31, 2022