This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//First you need install shamsi_date package from pub.dev and then import it. | |
import 'package:shamsi_date/shamsi_date.dart'; | |
void main (){ | |
final JalaliRange todayRange = | |
JalaliRange(start: Jalali.now(), end: Jalali.now()); | |
//Shamsi_date package doesn't support .add and .subtract (since this version) | |
//So we use DateTime and convert it to Jalali | |
final JalaliRange thisWeekRange = JalaliRange( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Checks if password has at least specialCount special character matches | |
bool hasMinSpecialChar(String password, int specialCount) { | |
String pattern = | |
r"^(.*?[$&+,\:;/=?@#|'<>.^*()%!-]){" + specialCount.toString() + ",}"; | |
return password.contains(new RegExp(pattern)); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Checks if password has at least numericCount numeric character matches | |
bool hasMinNumericChar(String password, int numericCount) { | |
String pattern = '^(.*?[0-9]){' + numericCount.toString() + ',}'; | |
return password.contains(new RegExp(pattern)); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Checks if password has at least uppercaseCount uppercase letter matches | |
bool hasMinUppercase(String password, int uppercaseCount) { | |
String pattern = '^(.*?[A-Z]){' + uppercaseCount.toString() + ',}'; | |
return password.contains(new RegExp(pattern)); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension StringExtentions on String { | |
String replaceFaNumToEnNum() { | |
const english = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']; | |
const farsi = ['۰', '۱', '۲', '۳', '۴', '۵', '۶', '۷', '۸', '۹']; | |
String value = this; | |
for (int i = 0; i < farsi.length; i++) { | |
value = value.replaceAll(farsi[i], english[i]); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/services.dart'; | |
import 'package:intl/intl.dart'; | |
class NumericTextFormatter extends TextInputFormatter { | |
@override | |
TextEditingValue formatEditUpdate( | |
TextEditingValue oldValue, TextEditingValue newValue) { | |
if (newValue.text.isEmpty) { | |