writing_guidelines 0.0.1
writing_guidelines: ^0.0.1 copied to clipboard
用于拼音或英语书写的 Flutter 组件库,提供“四线三格”背景,支持单格展示与流式布局。
Writing Guidelines #
A Flutter widget library for pinyin and English handwriting display. It provides a four-line grid background and supports both single-cell and flow layouts.
Features #
- Draws a four-line grid with customizable line color and thickness
WritingGuidelinesaccepts anychildand usesWritingGuidelinesStylefor unified styling- Convenient constructors:
WritingGuidelines.directandWritingGuidelines.text WritingGuidelinesWrapauto-wraps and detects the last item of each row
Quick Start #
Add the dependency in pubspec.yaml:
dependencies:
writing_guidelines: ^0.0.1
Import:
import 'package:writing_guidelines/weights.dart';
Usage #
WritingGuidelinesStyle #
final style = WritingGuidelinesStyle(
fontSize: 32,
lineColor: const Color(0xFFE0E0E0),
lineWidth: 1,
baselineRatio: 2 / 3,
heightRatio: 1.5,
);
WritingGuidelines(
style: style,
child: const Text('ma', style: TextStyle(fontSize: 32)),
)
Direct Constructor #
WritingGuidelines.direct(
fontSize: 28,
heightRatio: 1.5,
baselineRatio: 2 / 3,
child: const Text('mā', style: TextStyle(fontSize: 28)),
)
Text Mode #
WritingGuidelines.text(
'mǎ',
fontSize: 28,
textStyle: const TextStyle(fontSize: 28),
)
Flow Layout #
WritingGuidelinesWrap(
fontSize: 28,
runSpacing: 12,
children: const [
Text('mā', style: TextStyle(fontSize: 28)),
Text('má', style: TextStyle(fontSize: 28)),
Text('mǎ', style: TextStyle(fontSize: 28)),
Text('mà', style: TextStyle(fontSize: 28)),
],
)
String Extension #
import 'package:writing_guidelines/utils/pinyin_utils.dart';
final s = 'mā'.replaceAWithAlpha(); // mᾱ
API Notes #
- Grid height =
fontSize * heightRatio - Baseline position =
gridHeight * baselineRatio WritingGuidelinesWrapdetects the last item in each row and expands it to fill the remaining space
Example #
See the /example directory for more examples.
Contributing #
Issues and PRs are welcome.