Table of Contents
- ๐ Overview
- โจ Features
- ๐ฆ Installation
- ๐ Quick Start
- ๐ Parameters
- ๐ก Examples
- ๐ Special Features
- ๐จ Advanced Usage
- ๐ค Contributing
- ๐ Roadmap
- ๐ Known Issues
- โญ Show Your Support
๐ Overview
Arabic Justified Text is a Flutter package that provides beautiful text justification for Arabic text using Kashida (ู) instead of adding extra spaces between words. This creates a more natural and aesthetically pleasing appearance for justified Arabic text.
โจ Features
- โ Smart Kashida Distribution - Intelligently distributes Kashida across words
- โ Diacritics Support - Properly handles Arabic diacritics (Tashkeel)
- โ Mixed Text Support - Works with Arabic and English text together
- โ
Line Break Support - Respects
\ncharacters in text - โ Theme Integration - Inherits default text styles from your app theme
- โ
RichText Support - Advanced styling with
ArabicJustifiedRichText - โ Sacred Text Handling - Automatically excludes "Allah" (ุงููููฐู) from Kashida
- โ Customizable Exclusions - Add your own words to exclude from Kashida
- โ Performance Optimized - Efficient text processing
- โ RTL/LTR Support - Configurable text direction (RTL by default)
๐ฆ Installation
Add this to your package's pubspec.yaml file:
dependencies:
arabic_justified_text: ^0.0.8
Then run:
flutter pub get
๐ Quick Start
Basic Usage
import 'package:arabic_justified_text/arabic_justified_text.dart';
ArabicJustifiedText(
'ูู ุนุงูู
ุงูุชูููููุฌูุง ุงูุญุฏูุซุฉุ ุฃุตุจุญุช ุชุทุจููุงุช ุงููุงุชู ุงูู
ุญู
ูู ุฌุฒุกุงู ุฃุณุงุณูุงู ู
ู ุญูุงุชูุง ุงูููู
ูุฉ.',
)
With Custom Style
ArabicJustifiedText(
'ุงููุต ุงูุนุฑุจู ููุง',
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
color: Colors.blue,
),
)
With All Options
ArabicJustifiedText(
'ุฃุดูุฏ ุฃู ูุง ุฅูู ุฅูุง ุงููููฐูุ ูุฃู ู
ุญู
ุฏูุง ุฑุณูู ุงููููฐู',
style: TextStyle(fontSize: 16, height: 1.8),
enableKashida: true,
maxLines: 5,
overflow: TextOverflow.ellipsis,
textAlign: TextAlign.justify,
textDirection: TextDirection.rtl,
excludedWords: ['ู
ุญู
ุฏุง', 'ุฑุณูู'], // Optional: exclude specific words
)
๐ Parameters
ArabicJustifiedText
For simple text with single style.
| Parameter | Type | Default | Description |
|---|---|---|---|
text |
String |
required | The text to display |
style |
TextStyle? |
null |
Text style (inherits from theme if null) |
maxLines |
int? |
null |
Maximum number of lines |
overflow |
TextOverflow? |
null |
How to handle text overflow |
textDirection |
TextDirection |
TextDirection.rtl |
Text direction (RTL/LTR) |
textAlign |
TextAlign |
TextAlign.justify |
Text alignment |
enableKashida |
bool |
true |
Enable/disable Kashida justification |
excludedWords |
List<String>? |
null |
Words to exclude from Kashida |
ArabicJustifiedRichText
For complex text with multiple styles.
| Parameter | Type | Default | Description |
|---|---|---|---|
textSpan |
InlineSpan |
required | The text span to display |
maxLines |
int? |
null |
Maximum number of lines |
overflow |
TextOverflow? |
null |
How to handle text overflow |
textDirection |
TextDirection |
TextDirection.rtl |
Text direction (RTL/LTR) |
textAlign |
TextAlign |
TextAlign.justify |
Text alignment |
enableKashida |
bool |
true |
Enable/disable Kashida justification |
excludedWords |
List<String>? |
null |
Words to exclude from Kashida |
๐ก Examples
1. Simple Text
ArabicJustifiedText(
'ู
ุฑุญุจุงู ุจู ูู ุนุงูู
ุงูุจุฑู
ุฌุฉ ุงูุฌู
ูู',
)
2. Text with Diacritics (Tashkeel)
ArabicJustifiedText(
'ุจูุณูู
ู ุงูููููู ุงูุฑููุญูู
ููฐูู ุงูุฑููุญููู
ู',
style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold),
)
3. Multi-line Text with Line Breaks
ArabicJustifiedText(
'''ุงูุณุทุฑ ุงูุฃูู ู
ู ุงููุต
ุงูุณุทุฑ ุงูุซุงูู ู
ู ุงููุต
ุงูุณุทุฑ ุงูุซุงูุซ ู
ู ุงููุต''',
style: TextStyle(fontSize: 16, height: 2.0),
)
4. Mixed Arabic and English
ArabicJustifiedText(
'ุงุณุชุฎุฏู
Flutter ูุจูุงุก ุชุทุจููุงุช mobile ุฑุงุฆุนุฉ',
style: TextStyle(fontSize: 18),
)
5. With Maximum Lines
ArabicJustifiedText(
'ูุต ุทููู ุฌุฏุงู ูุญุชูู ุนูู ุงููุซูุฑ ู
ู ุงูููู
ุงุช ูุงูุฌู
ู...',
maxLines: 3,
overflow: TextOverflow.ellipsis,
)
6. Toggle Kashida On/Off
bool useKashida = true;
ArabicJustifiedText(
'ุงููุต ุงูุนุฑุจู ููุง',
enableKashida: useKashida,
)
๐ Special Features
Respectful Handling of Sacred Words
The package automatically excludes the word (ุงููููฐู) and its variations from Kashida application, preserving its traditional appearance.
// The word "ุงููููฐู" will never automatically receive Kashida
ArabicJustifiedText('ุจุณู
ุงููููฐู ุงูุฑุญู
ู ุงูุฑุญูู
')
// Result: ุจูุณูู
ุงููููฐู ุงููุฑุญู
ูู ุงููุฑุญููู
(ุงููููฐู remains unchanged)
Automatically excluded variations:
- ุงููููฐูุ ุงูููููุ ูฑููููฐูุ ููููฐูุ ูููููฐูุ ูุงููููฐูุ ุจุงููููฐูุ ุชุงููููฐู
Custom Word Exclusions
You can exclude additional words from Kashida application:
ArabicJustifiedText(
'ุงูููู
ุตู ูุณูู
ูุจุงุฑู ุนูู ูุจููุง ู
ุญู
ุฏ ูุนูู ุขูู ูุตุญุจู ุฃุฌู
ุนูู',
excludedWords: ['ู
ุญู
ุฏ', 'ุงูููู
'],
)
Use cases:
- ๐ Religious texts (prophets' names, sacred terms)
- ๐ Brand names or proper nouns
- โ๏ธ Technical terms that should remain unchanged
๐จ Advanced Usage
Using ArabicJustifiedRichText
โ ๏ธ Important:
ArabicJustifiedRichTextcurrently does not supportWidgetSpan. If your text contains widgets (icons, images, etc.), the Kashida justification will be disabled and it will fall back to standardRichTextrendering.
For complex text with multiple styles, colors, or interactions:
ArabicJustifiedRichText(
enableKashida: true,
textSpan: TextSpan(
style: TextStyle(fontSize: 18),
children: [
TextSpan(text: 'ุงููุต ุงูุนุงุฏู '),
TextSpan(
text: 'ุงููุต ุงูุนุฑูุถ',
style: TextStyle(fontWeight: FontWeight.bold, color: Colors.blue),
),
TextSpan(text: ' ุงูู
ุฒูุฏ ู
ู ุงููุต'),
],
),
)
๐ค Contributing
Contributions are welcome! Here's how you can help:
- ๐ Report Bugs - Open an issue describing the bug
- ๐ก Suggest Features - Share your ideas for improvements
- ๐ง Submit Pull Requests - Fix bugs or add features
- ๐ Improve Documentation - Help make docs better
- โญ Star the Repo - Show your support!
๐ Roadmap
WidgetSpan support for ArabicJustifiedRichText - Allow mixing text and widgets with KashidaAdd more customization options for Kashida densityPerformance improvements for very long textsSupport for other RTL languages (Persian, Urdu)
๐ Known Issues
- WidgetSpan not supported in ArabicJustifiedRichText - If you need to mix text with widgets (icons, images), use
enableKashida: falseor use standardRichText - Very long words might overflow on narrow screens (use
maxLinesto handle) - Performance may vary with extremely long texts (>10,000 characters)
โญ Show Your Support
If you find this package useful, please consider giving it a โญ on GitHub!