qsu library

Functions

arrCount(List array) Map<String, int>
Returns the number of duplicates for each unique value in the given array. The array values can only be of type String or Number.
arrGroupByMaxCount<T>(List<T> array, int maxLengthPerGroup) List<List<T>>
Separates the data in the given array into a two-dimensional array containing only the maximum number of elements. For example, if you have an array of 6 data in 2 groups, this function will create a 2-dimensional array with 3 lengths.
arrMove(List array, int from, int to) List
Moves the position of a specific element in an array to the specified position. (Position starts from 0.)
arrRepeat(dynamic array, int count) List
Repeats the data of an Array or Map a specific number of times and returns it as a 1d array.
arrShuffle<T>(List<T> array) List<T>
Shuffle the order of the given array and return.
arrTo1dArray(List array) List
Merges all elements of a multidimensional array into a one-dimensional array.
arrUnique(List array) List
Remove duplicate values from array and two-dimensional array data. In the case of 2d arrays, json type data duplication is not removed.
arrWithDefault(dynamic defaultValue, int length) List
Initialize an array with a default value of a specific length.
arrWithNumber(int start, int end) List<int>
Creates and returns an Array in the order of start...end values.
average(List<double> array) double
Returns the average of all numeric values in an array.
between(List<num> range, num number, {bool inclusive = false}) bool
Returns true if the first argument is in the range of the second argument ([min, max]). To allow the minimum and maximum values to be in the range, pass true for the third argument.
capitalizeEachWords(String str, {bool natural = false}) String
Converts every word with spaces to uppercase. If the naturally argument is true, only some special cases (such as prepositions) are kept lowercase.
capitalizeEverySentence(String str, {String? splitChar}) String
Capitalize the first letter of every sentence. Typically, the . characters to separate sentences, but this can be customized via the value of the splitChar argument.
capitalizeFirst(String str) String
Converts the first letter of the entire string to uppercase and returns.
contains(dynamic str, dynamic search, {bool exact = false}) bool
Returns true if the first string argument contains the second argument "string" or "one or more of the strings listed in the array". If the exact value is true, it returns true only for an exact match.
debounce(Function func, int timeout) Function
When the given function is executed repeatedly, the function is called if it has not been called again within the specified timeout. This function is used when a small number of function calls are needed for repetitive input events.
decodeBase64(String encodedStr) String
Decodes an encoded base64 string to a plain string.
encodeBase64(String str) String
Base64-encode the given string.
fileExt(String filePath) String
Returns only the extensions in the file path. If unknown, returns 'Unknown'.
fileName(String filePath, [bool withExtension = false]) String
Extract the file name from the path. Include the extension if withExtension is true.
fileSize(int bytes, {int? decimals}) String
Converts the file size in bytes to human-readable and returns it. The return value is a String and includes the file units (Bytes, MB, GB...). If the second optional argument value is included, you can display as many decimal places as you like.
funcTimes(int times, dynamic iteratee) List
Repeat iteratee n (times argument value) times. After the return result of each function is stored in the array in order, the final array is returned.
is2dArray(List array) bool
Returns true if the given array is a two-dimensional array.
isEmail(String email) bool
Checks if the given argument value is a valid email.
isEmpty(dynamic data) bool
Returns true if the passed data is empty or has a length of 0.
isEqual(dynamic leftOperand, [dynamic right1, dynamic right2]) bool
It compares the first argument value as the left operand and the argument values given thereafter as the right operand, and returns true if the values are all the same.
isEqualStrict(dynamic leftOperand, [dynamic right1, dynamic right2]) bool
It compares the first argument value as the left operand and the argument values given thereafter as the right operand, and returns true if the values are all the same. isEqual returns true even if the data types do not match, but isEqualStrict returns true only when the data types of all argument values match.
isObject(dynamic data) bool
Check whether the given data is of type Object. Returns false for other data types including Array.
isTrueMinimumNumberOfTimes(List<bool> conditions, {int? minimumCount}) bool
Returns true if the values given in the conditions array are true at least minimumCount times.
isUrl(String url, {bool withProtocol = false, bool strict = false}) bool
Returns true if the given data is in the correct URL format. If withProtocol is true, it is automatically appended to the URL when the protocol does not exist. If strict is true, URLs without commas (.) return false.
len(dynamic data) int
Returns the length of any type of data. If the argument value is null or undefined, 0 is returned.
md5Hash(String str) String
Converts String data to md5 hash value and returns it.
numberFormat(dynamic number) String
Return number format including comma symbol.
numRandom(int? min, int? max) int
Returns a random number (Between min and max).
objectId() String
Returns a random string hash of the ObjectId format (primarily utilized by MongoDB).
objTo1d(Map<String, dynamic> obj, {String? separator = '.'}) Map<String, dynamic>
Merges objects from the given object to the top level of the child items and displays the key names in steps, using a delimiter (. by default) instead of the existing keys. For example, if an object a has keys b, c, and d, the a key is not displayed, and the keys and values a.b, a.c, and a.d are displayed in the parent step.
objToArray(Map<String, dynamic> obj, [bool recursive = false]) List
Converts the given object to array format. The resulting array is a two-dimensional array with one key value stored as follows: [key, value]. If the recursive option is true, it will convert to a two-dimensional array again when the value is of type object.
objToQueryString(Map<String, dynamic> obj) String
Converts the given object data to a URL query string.
removeNewLine(String str, {String replaceTo = ''}) String
Removes \n, \r characters or replaces them with specified characters.
removeSpecialChar(String str, {String? exceptionCharacters}) String
Returns after removing all special characters, including spaces. If you want to allow any special characters as exceptions, list them in the second argument value without delimiters. For example, if you want to allow spaces and the symbols & and *, the second argument value would be ' &*'.
replaceBetween(String str, String startChar, String endChar, String replaceWith) String
Replaces text within a range starting and ending with a specific character in a given string with another string. For example, given the string abc<DEF>ghi, to change <DEF> to def, use replaceBetween('abc<DEF>ghi', '<', '>', 'def'). The result would be abcdefghi. Deletes strings in the range if replaceWith is not specified.
safeJSONParse(dynamic jsonString, [dynamic fallback = const {}]) → dynamic
Attempts to parse without returning an error, even if the argument value is of the wrong type or in JSON format. If parsing fails, it will be replaced with the object set in fallback. The default value for fallback is an empty object.
safeParseInt(dynamic value, {int? fallback, int? radix}) int
Any argument value will be attempted to be parsed as a Number type without returning an error. If parsing fails, it is replaced by the number set in fallback. The default value for fallback is 0. You can specify radix (default is decimal: 10) in the third argument.
sha1Hash(String str) String
Converts String data to sha1 hash value and returns it.
sha256Hash(String str) String
Converts String data to sha256 hash value and returns it.
sleep(int delay) Future<void>
Sleep function using Promise.
strCount(String str, String search) int
Returns the number of times the second String argument is contained in the first String argument.
strRandom(int length, {String? additionalCharacters}) String
Returns a random String containing numbers or uppercase and lowercase letters of the given length. The default return length is 12.
strShuffle(String str) String
Randomly shuffles the received string and returns it.
strToAscii(String str) List<int>
Converts the given string to ascii code and returns it as an array.
strToNumberHash(String str) int
Returns the specified string as a hash value of type number. The return value can also be negative.
strUnique(String? str) String
Remove duplicate characters from a given string and output only one.
trim(String str) String
Removes all whitespace before and after a string. Unlike JavaScript's trim function, it converts two or more spaces between sentences into a single space.
truncate(String str, int length, {String? ellipsis}) String
Truncates a long string to a specified length, optionally appending an ellipsis after the string.
truncateExpect(String str, int expectLength, {String? endStringChar}) String
The string ignores truncation until the ending character (endStringChar). If the expected length is reached, return the truncated string until after the ending character.
urlJoin(List<String?> args) String
Merges the given list argument (the beginning of the URL), joining it so that the slash (/) symbol is correctly included.