StrUtil class

字符串工具类

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

compareVersion(String version1, String version2) int
比较版本号
版本号由一个或多个修订号组成,各修订号由一个 '.' 连接。每个修订号由 多位数字 组成,可能包含 前导零 。每个版本号至少包含一个字符。修订号从左到右编号,下标从 0 开始,最左边的修订号下标为 0 ,下一个修订号下标为 1 ,以此类推。例如,2.5.33 和 0.1 都是有效的版本号。
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

blankToDefault(String? str, String defaultStr) String
如果字符串是{@code null}或者""或者空白,则返回指定默认字符串,否则返回字符串本身。
charIsNumber(String? str) bool
按照char方式比较是否是number
containsAny(String str, List<String> testStrs) bool
查找指定字符串是否包含指定字符串列表中的任意一个字符串
decode(List<int> codeUnits, [Encoding encoding = utf8]) String
使用默认的utf8转换List
emptyToDefault(String? str, String defaultStr) String
如果字符串是null或者"",则返回指定默认字符串,否则返回字符串本身。
emptyToNull(String? str) String?
当给定字符串为空字符串时,转换为null
encode(String str, [Encoding encoding = utf8]) List<int>
使用默认的utf8转换字符串数据为List
encodeAscii(String str) Uint8List
使用ascii转换字符串数据为Uint8List
encodeISO_8859_1(String str) Uint8List
使用ISO-8859-1转换字符串数据为Uint8List
encodeUtf8(String str) Uint8List
使用utf8转换字符串数据为Uint8List
endWithAny(String str, List<String> suffixes) bool
给定字符串是否以任何一个字符串结尾
给定字符串和数组为空都返回false
equalsIgnoreCase(String str, String str2) bool
忽略大小写匹配
hasBlank(List<String>? str) bool
指定字符串数组中,是否包含空字符串。
hasEmpty(List<String>? strs) bool
是否包含空字符串。
indicesOf(String str, Pattern pattern, [int start = 0]) List<int>
字符串匹配的所有下标
isAllBlank(List<String>? strs) bool
指定字符串数组中的元素,是否全部为空字符串。
isAllEmpty(List<String>? strs) bool
指定字符串数组中的元素,是否全部为空字符串。
isAllNotBlank(List<String>? args) bool
是否存都不为null或空对象或空白符的对象,通过hasBlank判断元素
isAllNotEmpty(List<String>? args) bool
指定字符串数组中的元素,是否都不为空字符串。
isBlank(String? str) bool
字符串是否为空白,\n, ,\r,都将视为空
isBlankOrUndefined(String? str) bool
检查字符串是否为null、空白串、“null”、“undefined”
isEmpty(String? str) bool
字符串是否为空
isLowerCase(String str) bool
给定字符串中的字母是否全部为小写
isNotBlank(String? str) bool
字符串是否为非空白.不为null,不为空字符串,不为空格、全角空格、制表符、换行符,等不可见字符
isNotEmpty(String? str) bool
字符串是否不为空
isNullOrUndefinedStr(String str) bool
是否为“null”、“undefined”,不做空指针检查
isUpperCase(String str) bool
给定字符串中的字母是否全部为大写
isUtf16(String str) bool
是否存在utf16编码字符
join(List<String> strs, [String separator = '']) String
遍历给定的字符串并按顺序拼接它们
lowerFirst(String str) String
返回此字符串的第一个字母为小写的副本,或原始字符串(如果它为空或已以小写字母开头)。
padLeft(String str, int length, String padChar) String
补充字符串以满足最小长度,如果提供的字符串大于指定长度,截断之 同:leftPad (org.apache.commons.lang3.leftPad)
repeat(String str, int count, [String delimiter = '']) String
重复某个字符
reversed(String str) String
以相反的顺序返回字符串
startWithAny(String str, List<String> prefixes) bool
给定字符串是否以任何一个字符串开始
给定字符串和数组为空都返回false
swapCase(String str) String
切换给定字符串中的大小写。 首字符小写转大写,首字符大写转小写
toCamelCase(String name, [String symbol = '_']) String
将连接符方式命名的字符串转换为驼峰式。如果转换前的下划线大写方式命名的字符串为空,则返回空字符串。
toLowerCase(String? str) String?
字符串转为小写
toPascalCase(String name) String
将下划线方式命名的字符串转换为帕斯卡式
toUnderlineCase(String str, [String symbol = '_']) String
将驼峰式命名的字符串转换为下划线方式。如果转换前的驼峰式命名的字符串为空,则返回空字符串。
toUpperCase(String? str) String?
字符串转为大写
uint8List(String str) Uint8List
转为无符号8位数组
upperFirst(String str) String
返回此字符串的第一个字母为大写的副本,或原始字符串(如果它为空或已以大写字母开头)。