Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD

persian tools

persian tools dart package which you can use in all platforms

an anthology of a variety of tools for the persian language which you can use in all platform that dart supports

usage

now let’s look at examples and how work with apis in package

  • adding ordinal suffixes – source

var number = 'سی سه'; // or سی | شصت | پنجاه دو
addordinalsuffix(number); // سی سوم | سی اُم | شصتم | پنجاه دوم

/// or use it as string extension method
number.withordinalsuffix // ... like so
  • removing ordinal suffixes – source

var number = 'چهل و سوم'; // سی سوم | سی اُم | شصتم | پنجاه دوم
removeordinalsuffix(number); // سی | شصت | پنجاه دو

/// or use it as string extension method
number.withoutordinalsuffix; // ... like so
  • converting persian words to number – source

final words = 'سه هزار دویست و دوازده';

/// use [wordstonumber] method to convert [words] to int number
wordstonumber(words); // 3212

/// use [wordstonumberstring] method to convert [words] to string
wordstonumberstring(words); // '3212' as string

/// [wordstonumberstring] also has two optional parameter
/// use [digit] optional parameter to convert the digits to specific local digits
/// use [addcomma] to add comma between the every 3 digits
wordstonumberstring(
words,
digits: digitlocale.fa,
addcomma: true,
); // '۳,۲۱۲' as string

/// or you can easily use extension methods on string object
words.convertwordstonumber(); // 3212

words.convertwordstonumberstring(); // '3212' as string
  • converting persian numbers to word – source

final stringdigit = '257,433';
final intdigit = -128;

/// use [numbertowordsstring] method to convert [stringdigit] to persian

numbertowordsstring(stringdigit); // 'دویست و پنجاه و هفت هزار و چهارصد و سی و سه'

/// [numbertowordsstring] also has an optional parameter
/// by default [ordinal] is [false], [true] makes the output an ordinal word

numbertowordsstring(stringdigit, ordinal: true); // 'دویست و پنجاه و هفت هزار و چهارصد و سی و سوم'

/// use [numbertowordsint] method to convert [intdigit] to persian
numbertowords(intdigit); // 'منفی صد و بیست و هشت'

/// [numbertowordsint] also has an optional parameter
/// by default [ordinal] is [false], [true] makes the output an ordinal word
numbertowords(intdigit, ordinal: true); // 'منفی صد و بیست و هشتم'

/// you can simply use extension methods on int or string objects
stringdigit.convertnumtowords(); // 'دویست و پنجاه و هفت هزار و چهارصد و سی و سه'

intdigit.convertnumtowords(); // 'منفی صد و بیست و هشت'
  • adding and removing separator to / from numbers – source

addcommas('3333'); // 3,333
addcommas('۸۲۳۳۴۵'); // 823,345

removecommas('654,562'); // 654562
removecommas('3,365.255'); // 3365.255

'11222'.addcomma // 11,222
'4,544.562'.removecomma // 4544.562
  • converting persian numbers to arabic / english numbers and reverse – source

convertartofa('السلام علیکم 14۱۲۳6٤٥'); // السلام علیکم 14۱۲۳6۴۵
convertartoen('persian tools : 123٥٦٧'); // persian tools : 123567
convertentofa('سلام این هارو فارسی کن : 22۲۳۴'); // سلام این هارو فارسی کن : ۲۲۲۳۴
convertfatoen('سلام این هارو اینگلیسی کن : 22۲۳۴'); // سلام این هارو اینگلیسی کن : 22234
  • checking a string has/is persian – source

ispersian('این یک متن فارسی است؟'); // true
ispersian('هل هذا نص فارسي؟'); // false
haspersian('this text includes فارسی'); // true
haspersian('это персидский س текст?'); // true
haspersian('أكد رئيس اللجنة العسكرية الممثلة لحكومة الوفاق أراضي البلاد.'); //true
  • validate iranian national id – source

var nationalid = '0684159414';
verifyiraniannationalid(nationalid); // true
  
///the nationalid should contain 10 digit, so the following verifications
///should return false
nationalid = '00000';
verifyiraniannationalid(nationalid); // false

/// verify nationalid with extension methods over [string] class
nationalid = '';
nationalid.isiraniannationalid; // false
  • find city and province name by national code – source

final place = getplacebyirannationalid('0084575948');
place?.city.name; // تهران مرکزی
place?.province.name; // تهران

/// get place with extension methods over [string] class
final nationalid = '2110990147';
nationalid.getplacenationalid?.city.name; // گرگان
nationalid.getplacenationalid?.province.name; // گلستان
var bill = bill(billid: 9174639504124, paymentid: 12908197, currency: 'rial');
bill.barcode // 917463950412400012908197
bill.billtype // برق 
bill.amount // 129000
bill.isbillvalid // false
bill.ispaymentidvalid // false
bill.isbillidvalid // true
// returns all the above getter as a map with same as getters
bill();
  • checking iban of the bank account (sheba) – source

var sheba = sheba('ir820540102680020817909002');
var bank = sheba(); // returns nullable object of bankinformation
bank?.nickname // nickname of bank
bank?.name // complete name of bank
bank?.persianname // complete persian name of bank
bank?.code // code of bank
// true means with sheba package can take account number, false means package can't
bank?.isaccountnumberavailable
bank?.accountnumber // account number in simple numbers
bank?.formattedaccountnumber // account number with hyphen
bank?.process
sheba.isvalid // true
  • validating atm card number – source

validatecardnumber('6219861034529007'); // true
validatecardnumber('6219861034529007'); // true
validatecardnumber('0000000000000000'); // false
validatecardnumber('621986103452900'); // false
  • validating iranians phone number – source

final phonenumber = '09022002580';

// phone number validator
phonenumbervalidator(phonenumber); // true

// phone number prefix
getphoneprefix(phonenumber); // 902

// phone number detail
final operatordetail = getphonenumberdetail(phonenumber);
operatordetail?.name; // ایرانسل
operatordetail?.provinces; // []
operatordetail?.base; // کشوری
operatordetail?.type; // simcarttype.both

/// you can also use this methods as string extension method

// phone number validator
phonenumber.isphonenumber; // true

// phone number prefix
phonenumber.phonenumberprefix; // 902

// phone number detail
phonenumber.phonenumberdetail?.name; // ایرانسل
  • finding banks name by card number – source

final cardnumber = '6037701689095443';

final bankinfo = getbanknamefromcardnumber(cardnumber);
bankinfo?.name; // بانک کشاورزی
bankinfo?.initcode; // 603770

/// you can also use this methods as string extension method

// get bank info from string
cardnumber.banknamefromcard?.name; // بانک کشاورزی
  • getting information from vehicle plate – source

var motorcycleplate = plate(plate: '12345678');
motorcycleplate.info.type // motorcycle
motorcycleplate.info.template // 123-45678
motorcycleplate.info.province // مرکز تهران
motorcycleplate.info.category // null because its type is motorcycle
motorcycleplate.isvalid // true

// because of persian language you may see plate in wrong form
var carplate = plate(plate: '12ب14547');
carplate.info.type // car
carplate.info.template // 12{b}145{iran}47 , b=ب  iran=ایران
carplate.info.province // مرکزی
carplate.info.category // شخصی
carplate.isvalid // true

// you can also create [plate] with below string extension method
var motorplate =  '12345678'.createvehicleplate;
motorplate.info.type // motorcycle
motorplate.info.template // 123-45678
motorplate.info.province // مرکز تهران
motorplate.info.category // null because its type is motorcycle
motorplate.isvalid // true
  • fixing and decoding urls – source

var url = 'wss://hostname.domain/?q=i am a wrong query';
urlfix(url); // wss://hostname.domain/?q=i%20am%20a%20wrong%20query

Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD

Top