Useful utilities for developers building Arabic and RTL Flutter/Dart applications.
arabic_dev_utils is a modular toolkit for MENA app development: normalize
and classify Arabic text, search across it in a diacritic-insensitive way,
convert between Arabic and Western digits, and infer RTL/LTR direction —
without pulling in a framework or reimplementing locale-aware number
formatting yourself.
Install
dependencies:
arabic_dev_utils: ^0.1.0
Quick start
import 'package:arabic_dev_utils/arabic_dev_utils.dart';
// Text normalization
ArabicText.isArabic('مرحبا'); // true
ArabicText.normalize('أَحْمَد'); // 'احمد'
ArabicText.stripInvisibleChars('محمدعلي'); // 'محمدعلي'
// Search
ArabicSearch.matches(query: 'احمد', text: 'أَحْمَد بن علي'); // true
ArabicSearch.rank('علي', ['محمد علي', 'علي حسن']); // ['علي حسن', 'محمد علي']
// Numbers
ArabicNumbers.toArabicDigits('100 ريال'); // '١٠٠ ريال'
ArabicNumbers.format(1234, locale: 'ar_EG'); // '١٬٢٣٤'
// RTL/direction
ArabicDirection.dominantDirection('مرحبا hello'); // ArabicTextDirection.mixed
ArabicDirectionality(
basedOn: 'مرحبا',
child: Text('مرحبا'), // rendered right-to-left automatically
);
Features
Text (ArabicText)
isArabic,isArabicOnly,isMixed— script detectionremoveDiacritics,removeTatweel— strip tashkeel and kashidanormalizeAlef,normalizeYeh,normalizeTehMarbuta— variant normalizationnormalize— applies all of the above in one callstripInvisibleChars— see Why invisible-character stripping matterswordCount,charCount— Arabic-aware counting
Search (ArabicSearch)
matches— diacritic/tatweel/alef/yeh-insensitive containment checknormalizeForSearch— the aggressive normalization used internallytokenize— normalized search tokensrank— sort candidates by match quality (exact → prefix → contains)
Numbers (ArabicNumbers)
toArabicDigits,toEnglishDigits— convert between ASCII, Arabic-Indic (٠-٩), and Extended Arabic-Indic/Persian (۰-۹) digitscontainsArabicDigits— detect Arabic-Indic digitsformat— a thin, documented wrapper aroundpackage:intl'sNumberFormatfor Arabic-digit output; it exists for discoverability, not becauseintlis inadequate
RTL/direction (ArabicDirection)
isRtl,isLtr,isMixedDirection— direction checksdominantDirection— returns anArabicTextDirection(rtl,ltr,mixed,neutral)ArabicDirectionality— aDirectionality-wrapping widget that infers direction from a string.package:intl'sBidiclass already exposes direction detection, but this widget is easier to discover and use for the common "set this widget's direction from a string" case.
Why invisible-character stripping matters
Text copied from WhatsApp, Word, or many mobile keyboards can carry invisible characters — zero-width joiners, zero-width spaces, bidi control marks — that render identically to the naked eye but break equality checks, search, and diffs:
const fromWhatsApp = 'محمدعلي'; // contains a hidden ZWJ
const typedByHand = 'محمدعلي';
fromWhatsApp == typedByHand; // false — a silent bug
ArabicText.stripInvisibleChars(fromWhatsApp) ==
ArabicText.stripInvisibleChars(typedByHand); // true
Without stripping, this shows up as duplicate-looking entries in a database, search results that silently miss a match, or a diff tool reporting a change between two strings that look the same on screen.
Example app
See example/lib/main.dart for a full demo of all
four modules, including a live search box over a list of Arabic names.
Contributing
Issues and pull requests are welcome. Please include tests for any new behavior and keep new public API fully documented with dartdoc comments.
License
MIT — see LICENSE.
Libraries
- arabic_dev_utils
- Utilities for developers building Arabic and RTL Flutter/Dart applications: text normalization, invisible-character cleanup, Arabic-aware search, digit conversion, and RTL direction helpers.