kashi library

Kashi for Flutter: Persian, RTL-first.

MaterialApp(
  theme: KashiTheme.light(),
  darkTheme: KashiTheme.dark(),
  locale: const Locale('fa'),
  supportedLocales: const [Locale('fa'), Locale('en')],
  localizationsDelegates: GlobalMaterialLocalizations.delegates,
)

Classes

Bank
An Iranian bank: Persian name and a Latin slug (the same slugs as @kashi-ui/bank-logos).
CardNumberField
شماره کارت: grouped in fours, Luhn-checked, with the bank's name as soon as the first six digits are in.
IbanField
شماره شبا: IR + 24 digits, ISO 13616 check, with the bank's name.
JalaliCalendar
The Jalali month calendar, the same as .k-calendar on the web: weeks start on Saturday, month and year selects, today in brand with a dot, the selected day filled, Fridays and holidays in red.
JalaliDate
A Jalali (Solar Hijri) date.
JalaliDateField
The date field, the same as the web DatePicker: ۱۴۰۳/۰۱/۰۱, a calendar button at the end, and Kashi's popover.
KashiButton
Kashi's button, the same as .k-btn on the web: 40px (md) tall, 14/600 text, --k-control-padding-x-*, a 1px border, radius control, a 6px gap between icon and label, hover colors from the tokens, a 0.97 press scale and the focus ring.
KashiCard
Kashi's card, the same as .k-card: radius surface (20), a hairline border-secondary, bg-elevated, a header (17/600 title, 14px tertiary description, 4px apart), a body and a footer with a top border. Padding is --k-control-surface-padding-* (24 by default); the footer uses 0.66 of it vertically.
KashiColors
Kashi's semantic colors for the current theme: Theme.of(context).extension<KashiColors>()! or KashiColors.of(context).
KashiComponent
Component size defaults, the same as --k-<component>-<prop>-<step> (e.g. --k-avatar-size-md).
KashiControl
Control sizes (buttons, fields, selects, menu items, calendar days), the same as --k-control-* on the web.
KashiField
Kashi's field frame, the same as .k-field on the web: the label above, a 40px control with a 4px focus ring, a hover border, and the hint or error below. Wrap any input in it:
KashiFontSize
Font sizes in logical pixels; Persian reads a little smaller than Latin, so the body size is 15.
KashiInputBorder
An outline border that also paints Kashi's focus ring outside itself (box-shadow: 0 0 0 4px var(--k-ring-brand)), so the ring hugs the field exactly and animates with the border.
KashiLeading
Line heights: Persian letters have dots and teeth and need taller lines.
KashiMetrics
Sizes after Kashi's global knobs, the same as --k-density, --k-radius-factor and --k-text-scale on the web. KashiTheme.light(density: 0.875) puts one in the theme; widgets read KashiMetrics.of(context).
KashiMotion
Motion durations and curves, the same as the CSS.
KashiPalette
Kashi's base palette (Persian names: firoozeh, lajvard, zafaran, anar, pesteh, shab).
KashiRadius
Corner radii in logical pixels. control for buttons and fields, surface for cards and dialogs.
KashiShadows
Kashi's elevation shadows for the current theme (--k-shadow-*): KashiShadows.of(context).lg.
KashiSpace
Spacing in logical pixels (multiples of 4).
KashiStrings
Built-in texts in Persian or English, picked from the app's locale (Locale('en') → English).
KashiText
Kashi's text roles, the same as text in @kashi-ui/tokens.
KashiTextRole
One text role: a font size, weight and line height from the type scale (--k-type-<role>-* on the web).
KashiTheme
Material themes built from Kashi's tokens: the same colors, radii, shadows and text roles as the web.
KashiWeight
Font weights.
MobileField
موبایل: accepts +98, 0098 and 9…; shows the operator.
NationalIdField
کد ملی: 10 digits with the check digit validated.
Operator
PostalCodeField
کد پستی: 10 digits as 12345-67890.
PriceField
مبلغ: thousands separators while typing and the amount in words underneath («یک میلیون و … تومان»).

Extensions

KashiContext on BuildContext
context.kashi.textBrand — Kashi's semantic colors for the current theme.

Constants

iranFixedHolidays → const Map<String, String>
Fixed official holidays of the solar calendar, keyed month-day. Lunar holidays move every year: pass them through extra (keys month-day Jalali, or yyyy-mm-dd Gregorian).
jalaliMonths → const List<String>
jalaliMonthsEn → const List<String>
kashiFontFamily → const String
The Kashi typeface bundled with this package (SIL OFL 1.1).
weekdays → const List<String>
Weekdays starting on Saturday.
weekdaysEn → const List<String>
weekdaysShort → const List<String>

Functions

bankByCard(String value) → Bank?
The bank from the first six digits, or null.
bankByIban(String value) → Bank?
formatCardNumber(String value) → String
6037991234567890 → 6037 9912 3456 7890.
formatIban(String value) → String
IR06 0170 0000 ….
formatJalali(DateTime date, {JalaliStyle style = JalaliStyle.numeric, bool english = false, bool? persianDigits}) → String
۱۴۰۵/۰۸/۰۴, ۴ آبان ۱۴۰۵ or دوشنبه ۴ آبان ۱۴۰۵.
formatMobile(String value) → String
0912 345 6789.
formatMoney(num amount, {bool rial = false, bool showUnit = true, bool persianDigits = true}) → String
1250000 → ۱٬۲۵۰٬۰۰۰ تومان.
formatNumber(num value, {bool persianDigits = true}) → String
Thousands separators: 1250000 → ۱٬۲۵۰٬۰۰۰ (or 1,250,000 with persianDigits: false).
formatPostalCode(String value) → String
1234567890 → 12345-67890.
ibanDigits(String value) → String
The 24 IBAN digits without IR.
iranHoliday(DateTime date, {Map<String, String> extra = const {}, bool friday = true}) → String?
The holiday's name, 'جمعه' for Fridays, or null.
isLeapJalaliYear(int jy) → bool
isValidCardNumber(String value) → bool
A 16-digit card number with a valid Luhn checksum.
isValidIban(String value) → bool
Iranian IBAN (شبا): IR + 24 digits with ISO 13616 check digits.
isValidJalaliDate(int jy, int jm, int jd) → bool
isValidMobile(String value) → bool
isValidNationalId(String value) → bool
Iranian national ID (10 digits with a check digit). Persian/Arabic digits, spaces and dashes are fine.
isValidPostalCode(String value) → bool
10-digit Iranian postal code.
jalaliMonthLength(int jy, int jm) → int
jalaliWeekday(DateTime date) → int
Weekday starting on Saturday: 0 = Saturday … 6 = Friday.
mobileOperator(String value) → Operator?
normalizeMobile(String value) → String
+98912…, 0098912…, 98912…, 912… → 0912….
numberToWords(int value) → String
1250000 → «یک میلیون و دویست و پنجاه هزار». Whole numbers up to 999 trillion.
onlyDigits(String value) → String
Keeps only the digits (in any script), returned as Latin.
parseJalali(String text) → DateTime?
Reads ۱۴۰۳/۵/۱۲, 1403-05-12 or ۱۴۰۳ ۰۵ ۱۲; null when invalid.
showJalaliDatePicker(BuildContext context, {DateTime? initialDate, DateTime? firstDate, DateTime? lastDate, Map<String, String> holidays = const {}}) → Future<DateTime?>
Opens Kashi's date popover (.k-datepicker__popover: 16px padding, radius surface, a hairline border and shadow xl) as a dialog. Picking a day returns it at once, like the web; tapping outside returns null.
toEnDigits(String value) → String
Persian and Arabic digits to Latin: ۱۴۰۳ → 1403.
toFaDigits(Object value) → String
Latin digits to Persian: 1403 → ۱۴۰۳.
toGregorian(int jy, int jm, int jd) → DateTime
Jalali → Gregorian DateTime at local midnight.
toJalali(DateTime date) → JalaliDate
Gregorian (local date) → Jalali.