quote_painter 0.2.3
quote_painter: ^0.2.3 copied to clipboard
Flutter package for rendering styled text on image/video canvas with gradient fill, stroke, shadow, decorative quotation marks, line badges, and themes.
quote_painter #
A high-performance Flutter package for rendering beautifully styled text, inspirational quotes, titles, and captions over image/video canvas surfaces with gradients, outlines, multi-layer shadows, background highlight badges, decorative quote glyphs, ready-to-use themes, per-line overrides, and PNG export.
Now available on pub.flutter-io.cn/packages/quote_painter.
β¨ Features #
- π Gradient Fills β Full support for Linear and Radial gradients across text characters or solid colors.
- ποΈ Strokes & Outlines β Configurable stroke widths, outline colors, and join styles to make text readable against any backdrop.
- π Multi-Layer Shadows β Customizable blur radius, shadow color, and 2D offset for crisp depth.
- π·οΈ Line Badges & Highlights β Add colored or gradient background pills/badges behind text lines (
LineHighlight). - β Decorative Quotation Marks β Typographic quote mark embellishments (
QuoteMarkStyle) with smart placement (QuoteMarkPlacement). - π¨ Pre-built Typography Themes β Quick start with
QuoteThemes.editorial,QuoteThemes.cyberpunkNeon,QuoteThemes.minimalistDark,QuoteThemes.sunsetGlow, andQuoteThemes.highlightedBadge. - π Auto-Wrapping Helper β Split continuous text into properly constrained lines using
QuotePainter.fromText(...). - π Per-Line Customization β Override font size, color, gradient, stroke, and text alignment (
left,center,right) per individual line. - π Unicode & Mixed Scripts β Full emoji, multilingual, and complex script support via Flutter's
TextPainter. - πΌοΈ High-Resolution PNG Export β Convert canvas designs directly to
Uint8Listbytes at custom pixel ratios (2x, 3x, 4x for 4K exports).
π¦ Installation #
Add quote_painter to your Flutter project:
flutter pub add quote_painter
Or add it to your pubspec.yaml dependencies:
dependencies:
quote_painter: ^0.2.0
Then run flutter pub get and import:
import 'package:quote_painter/quote_painter.dart';
π Usage #
1. Basic Quote Canvas with Presets #
Display a styled quote using built-in theme presets:
import 'package:flutter/material.dart';
import 'package:quote_painter/quote_painter.dart';
class QuoteCardDemo extends StatelessWidget {
const QuoteCardDemo({super.key});
@override
Widget build(BuildContext context) {
return Center(
child: QuoteCanvas(
lines: const [
TextLine('βThe greatest glory in living'),
TextLine('lies not in never falling,'),
TextLine('but in rising every time we fall.β'),
TextLine(
'β Nelson Mandela',
style: LineStyle(
fontSize: 16,
fontWeight: FontWeight.w400,
color: Colors.white70,
textAlign: TextAlign.right,
),
),
],
quoteStyle: QuoteThemes.cyberpunkNeon,
width: 360,
height: 260,
backgroundDecoration: BoxDecoration(
borderRadius: BorderRadius.circular(16),
color: const Color(0xFF0F172A),
boxShadow: const [
BoxShadow(
color: Colors.black45,
blurRadius: 16,
offset: Offset(0, 8),
),
],
),
padding: const EdgeInsets.all(24),
),
);
}
}
2. Auto-Wrapping Long Quotes (fromText) #
Generate canvas lines automatically for continuous text:
final painter = QuotePainter.fromText(
text: 'Creativity is intelligence having fun.',
quoteStyle: QuoteThemes.editorial,
maxWidth: 320,
maxHeight: 200,
);
3. Decorative Quotation Marks & Line Badges #
final customStyle = QuoteStyle(
fontSize: 24,
fontWeight: FontWeight.bold,
color: Colors.white,
defaultHighlight: const LineHighlight(
color: Color(0x3300E5FF),
borderRadius: BorderRadius.all(Radius.circular(6)),
padding: EdgeInsets.symmetric(horizontal: 10, vertical: 4),
),
quoteMarkStyle: const QuoteMarkStyle(
show: true,
color: Color(0x4400E5FF),
fontSize: 50,
placement: QuoteMarkPlacement.topLeft,
),
);
4. Exporting Canvas to PNG #
Easily capture the painted canvas as a PNG image for sharing or video composition:
import 'dart:typed_data';
import 'package:flutter/material.dart';
import 'package:quote_painter/quote_painter.dart';
final GlobalKey canvasKey = GlobalKey();
// In widget tree:
QuoteCanvas(
key: canvasKey,
lines: lines,
quoteStyle: style,
width: 1080,
height: 1920,
)
// In export button callback:
Future<void> saveQuoteImage() async {
final Uint8List pngBytes = await exportToPng(canvasKey, pixelRatio: 3.0);
// Save or share pngBytes
}
π οΈ Architecture & API Reference #
| Class | Description |
|---|---|
QuoteCanvas |
Interactive/static Flutter widget managing layout, bounding constraints, and export boundary. |
QuotePainter |
Core CustomPainter rendering lines, gradients, strokes, shadows, and quote marks. |
QuotePainter.fromText |
Factory constructing QuotePainter with automatic word-wrap layout. |
QuoteStyle |
Styling configuration (font, gradients, drop shadows, highlights, quote marks). |
QuoteThemes |
Out-of-the-box typography presets (editorial, cyberpunkNeon, minimalistDark, sunsetGlow, etc.). |
LineHighlight |
Background badge / pill styling per text line. |
QuoteMarkStyle |
Typographic quotation marks configuration and placement. |
exportToPng |
Headless rasterizer converting a QuoteCanvas into PNG bytes. |
π§ͺ Testing #
flutter test
π Ecosystem & Related Packages #
Explore complementary production-grade libraries built for high-performance Flutter & Dart development:
| Package | Description | Version |
|---|---|---|
country_mobile_validator |
Zero-dependency per-country mobile validation (249 ISO regions). | ^0.2.0 |
currency_field_formatter |
Exact cursor-tracking currency and financial input formatter. | ^1.1.0 |
ambient_backdrop_glow |
Dynamic ambient background glow & fluid OKLab mesh gradients. | ^1.1.0 |
segmented_ring_painter |
High-performance segmented progress & concentric activity rings. | ^1.1.0 |
scratch_reveal |
GPU-accelerated scratch cards with sub-ms bitmask area tracking. | ^1.1.0 |
offline_outbox |
Offline-first resilient transactional outbox and retry queue. | ^1.1.0 |
cron_schedule |
Pure-Dart cron expression parser, predictor & fluent builder. | ^1.1.0 |
flutter_whisper |
On-device speech-to-text transcription powered by whisper.cpp. | ^0.2.0 |
waveform_pro |
Audio waveform visualizer with discrete bars, splines & live buffer. | ^1.1.2 |
π License #
This package is licensed under the MIT License.