custom_text_engine 0.1.1
custom_text_engine: ^0.1.1 copied to clipboard
Custom text engine with hyphenation for Flutter (custom layout, justify, inline elements).
custom_text_engine #
A custom text layout engine for Flutter with paragraph-level layout, inline elements, manual justify, and hyphenation-oriented line breaking.
Status: active development. Public API may change until
0.xstabilizes.
What you get #
This package can be used in two ways:
-
Ready-to-use widget:
AdvancedText
Quickly render yourParagraphBlocks usingCustomPaint. -
Low-level engine API:
AdvancedLayoutEngine
Build aCustomTextLayout(list ofLineLayouts) and paint/measure/interact with it however you want.
Features #
- Paragraph layout into lines with custom wrapping rules.
- Inline elements: text runs, hard line breaks, indents, extensible custom elements.
- Manual justify support (space distribution).
- Hyphenation hooks (soft hyphen / forced split strategies).
- (Optional) caching of measured elements / paragraphs (implementation-dependent).
Installation #
Add dependency:
dependencies: custom_text_engine: ^0.1.0
Then:
flutter pub get
Quick start (widget) #
If you just want to render text with this engine, use AdvancedText.
import 'package:flutter/material.dart'; import 'package:custom_text_engine/custom_text_engine.dart';
class DemoPage extends StatelessWidget { const DemoPage({super.key});
@override Widget build(BuildContext context) { final paragraphs =
return Scaffold( appBar: AppBar(title: const Text('custom_text_engine')), body: Padding( padding: const EdgeInsets.all(16), child: AdvancedText( paragraphs: paragraphs, debugPaint: false, ), ), ); } }
Quick start (engine) #
Use AdvancedLayoutEngine when you want custom rendering, hit-testing, selection, annotations, etc.
import 'package:flutter/material.dart'; import 'package:custom_text_engine/custom_text_engine.dart';
final engine = AdvancedLayoutEngine( paragraphs: paragraphs, globalMaxWidth: 420, globalTextAlign: TextAlign.justify, );
final layout = engine.layoutAllParagraphs();
// layout.lines -> List
Example app #
A runnable Flutter example app is included in example/.
cd example flutter run
Public API #
Do not import files from lib/src/**.
Use only:
import 'package:custom_text_engine/custom_text_engine.dart';
This keeps implementation private and allows internal refactors without breaking users. [web:69]
Contributing #
PRs and issues are welcome — see CONTRIBUTING.md.
License #
Apache-2.0 (see LICENSE).
Author #
1bgn 137element@gmail.com