dartkt 1.0.4

Dart native
Flutter Android iOS

A dart library for lazier programmers. Functions are ported from kotlin.

DartKT #

A dart library for lazier programmers.

Getting Started #

Add dependence of dartkt to your project. The last version is 1.0.2 .

dependencies:
    ... ...
    dartkt: ^1.0.2

Functions #

Functions in the library are ported from kotlin, also included some useful utils like http.

Here is a list for cognition:

ClassMethodDefinitionNote
KTObjectExtensionalsoT also(void Function(T) block)
letR let<R>(R Function(T) block)
takeIfT takeIf(bool Function(T) block)
takeUnlessT takeUnless(bool Function(T) block)
HttpMethodGET, HEAD, POST, PUT, DELETE
HttpResponse
HttpError
httphttpFuture<HttpResponse> http(String url, HttpMethod method, {Map<String, String> param,String mimeType='application/json', String body, Map<String, String> postParam, Map<String, String> fileParam, Map<String, String> headers, int timeout=15})
httpGetFuture<HttpResponse> httpGet(String url, {Map<String, String> param, Map<String, String> headers})
httpPostFuture<HttpResponse> httpPost(String url, {Map<String, String> param, String body, Map<String, String> headers})
DownloadStateStart, Progress, Complete, Error
DownloadCallbackvoid Function(DownloadState state, int position, int filesize, String error)
downloaddownloadFuture<bool> download(String url, String localFile, DownloadCallback callback)
KTPairtoListList<T> toList()
KTTripletoListList<A> toList()
KTStringExtensionsubstringBeforeString substringBefore(Pattern pattern)
substringAfterString substringAfter(Pattern pattern)
substringBeforeLastString substringBeforeLast(Pattern pattern)
substringAfterLastString substringAfterLast(Pattern pattern)
removeRangeString removeRange(int startIdx, int endIdx)
removePrefixString removePrefix(Pattern pattern)
removeSuffixString removeSuffix(Pattern pattern)
removeSurroundingString removeSurrounding(Pattern pattern)
replaceBeforeString replaceBefore(Pattern pattern, String replacement)
replaceAfterString replaceAfter(Pattern pattern, String replacement)
replaceAfterLastString replaceAfterLast(Pattern pattern, String replacement)
replaceBeforeLastString replaceBeforeLast(Pattern pattern, String replacement)
linesList<String> lines()
dropString drop(int n)
dropLastString dropLast(int n)
filterString filter(bool Function(String) block)
filterIndexedString filterIndexed(bool Function(int, String) block)
filterNotString filterNot(bool Function(String) block)
reversedString reversed()
toListList<String> toList()
mapList<T> map<T>(T Function(String) block)
mapIndexedList<T> mapIndexed<T>(T Function(int, String) block)
forEachforEach(void Function(String) action)
forEachIndexedforEachIndexed(void Function(int, String) action)
reduceString reduce(String Function(String, String) block)
reduceIndexedString reduceIndexed(String Function(int, String, String) block)
toIntint toInt()
toDoubledouble toDouble()
toBoolbool toBool()
base64encodeString base64encode()
base64decodeString base64decode()
toIntListList<int> toIntList()
lastPathPartString lastPathPart()
getPathDirectoryString getPathDirectory()
toJsonEncodedString toJsonEncoded()
toTitleUpperCaseString toTitleUpperCase()
appendPathPartString appendPathPart(String part)
extensionString extension()
replaceTagString replaceTag(String tag, String Function() block)
skipEmptyLineString skipEmptyLine()
toPairKTPair<String, String> toPair()
savesave(File f)
asFileWriteTextFile asFileWriteText(String s)
asFileReadTextString asFileReadText()
asFileMkdirsasFileMkdirs()
asFileFile asFile()
hashString hash([String alg])
md5sha1String get md5sha1
KTListExtension<T>findT find(bool Function(T) block)
findLastT findLast(bool Function(T) block)
indexOfFirstint indexOfFirst(bool Function(T) block)
indexOfLastint indexOfLast(bool Function(T) block)
dropList<T> drop(int n)
dropLastList<T> dropLast(int n)
filterList<T> filter(bool Function(T) block)
filterIndexedList<T> filterIndexed(bool Function(int, T) block)
filterNotList<T> filterNot(bool Function(T) block)
sliceList<T> slice(int startIdx, int endIdx)
sortByList<T> sortBy(int Function(T, T) block)
sortByDescendingList<T> sortByDescending(int Function(T, T) block)
map2List<R> map2<R>(R Function(T) block)overrided
map2IndexedList<R> map2Indexed<R>(R Function(int, T) block)
distinctList<T> distinct()
distinctByList<T> distinctBy<R>(R Function(T) block)
allbool all(bool Function(T) block)
anybool any(bool Function(T) block)
countint count(bool Function(T) block)
forEachIndexedforEachIndexed(void Function(int, T) block)
nonebool none(bool Function(T) block)
reduceIndexedT reduceIndexed(T Function(int, T, T) block)
minusminus(List<T> list)
joinToStringString joinToString([String sep = ',', String Function(T) block])
toStringListList<String> toStringList()
toMapMap<K, V> toMap<K, V>()
mapToC mapTo<R, C extends List<R>>(C dest, R Function(T))
mapIndexedToC mapIndexedTo<R, C extends List<R>>(C dest, R Function(int, T) block)
filterToC filterTo<C extends List<T>>(C dest, bool Function(T) block)
filterIndexedToC filterIndexedTo<C extends List<T>>(C dest, bool Function(int, T) block)
filterNotToC filterNotTo<C extends List<T>>(C dest, bool Function(T) block)
toGridDataList<List<T>> toGridData([int column = 1])
KTListListExtension<T>toListDataList<T> toListData()
KTSetExtension<T>findT find(bool Function(T) block)
findLastT findLast(bool Function(T) block)
indexOfFirstint indexOfFirst(bool Function(T) block)
indexOfLastint indexOfLast(bool Function(T) block)
dropSet<T> drop(int n)
dropLastSet<T> dropLast(int n)
filterSet<T> filter(bool Function(T) block)
filterIndexedSet<T> filterIndexed(bool Function(int, T) block)
filterNotSet<T> filterNot(bool Function(T) block)
sliceSet<T> slice(int startIdx, int endIdx)
sortBySet<T> sortBy(int Function(T, T) block)
sortByDescendingSet<T> sortByDescending(int Function(T, T) block)
map2Set<R> map2<R>(R Function(T) block)overrided
map2IndexedSet<R> map2Indexed<R>(R Function(int, T) block)
distinctSet<T> distinct()
distinctBySet<T> distinctBy<R>(R Function(T) block)
allbool all(bool Function(T) block)
anybool any(bool Function(T) block)
countint count(bool Function(T) block)
forEachIndexedforEachIndexed(void Function(int, T) block)
nonebool none(bool Function(T) block)
reduceIndexedT reduceIndexed(T Function(int, T, T) block)
minusminus(Set<T> s)
joinToStringString joinToString([String sep = ',', String Function(T) block])
toStringListSet<String> toStringList()
toMapMap<K, V> toMap<K, V>()
mapToC mapTo<R, C extends Set<R>>(C dest, R Function(T) block)
mapIndexedToC mapIndexedTo<R, C extends Set<R>>(C dest, R Function(int, T) block)
filterToC filterTo<C extends Set<T>>(C dest, bool Function(T) block)
filterIndexedToC filterIndexedTo<C extends Set<T>>(C dest, bool Function(int, T) block)
filterNotToC filterNotTo<C extends Set<T>>(C dest, bool Function(T) block)
KTMapExtension<K, V>toListList<KTPair<K, V>> toList()
mapToListList<R> mapToList<R>(R Function(MapEntry<K, V>) block)
forEachEntryforEachEntry(void Function(MapEntry<K, V>) block)
allbool all(bool Function(MapEntry<K, V>) block)
anybool any(bool Function(MapEntry<K, V>) block)
countint count(bool Function(MapEntry<K, V>) block)
nonebool none(bool Function(MapEntry<K, V>) block)
filterKeysMap<K, V> filterKeys(bool Function(K) block)
filterValuesMap<K, V> filterValues(bool Function(V) block)
filterMap<K, V> filter(bool Function(MapEntry<K, V>) block)
filterNotMap<K, V> filterNot(bool Function(MapEntry<K, V>) block)
addadd(Map<K, V> m)
minusminus(Map<K, V> m)
filterToMap<K, V> filterTo<M extends Map<K, V>>(M dest, bool Function(MapEntry<K, V>) block)
filterNotToMap<K, V> filterNotTo<M extends Map<K, V>>(M dest, bool Function(MapEntry<K, V>) block)
filterKeysToMap<K, V> filterKeysTo<M extends Map<K, V>>(M dest, bool Function(K) block)
filterValuesToMap<K, V> filterValuesTo<M extends Map<K, V>>(M dest, bool Function(V) Block)
mapToMap<K2, V2> mapTo<K2, V2, C extends Map<K2, V2>>(C dest, MapEntry<K2, V2> Function(MapEntry<K, V>) block)
mapToListToList<R> mapToListTo<R, C extends List<R>>(C dest, R Function(MapEntry<K, V>) block)
mapKeysToMap<K2, V2> mapKeysTo<K2, V2, C extends Map<K2, V2>>(C dest, MapEntry<K2, V2> Function(K) block)
mapKeysToListToList<R> mapKeysToListTo<R, C extends List<R>>(C dest, R Function(K) block)
mapValuesToMap<K2, V2> mapValuesTo<K2, V2, C extends Map<K2, V2>>(C dest, MapEntry<K2, V2> Function(V) block)
mapValuesToListToList<R> mapValuesToListTo<R, C extends List<R>>(C dest, R Function(V) block)
RegexUtilisStringRegbool isStringReg(String str, int type)
isNumberRegbool isNumberReg(String str, int type)
isEmailbool isEmail(String str)
isPhoneNumberbool isPhoneNumber(String str)
isCellPhoneNumberbool isCellPhoneNumber(String str)
isChinesePhoneNumberbool isChinesePhoneNumber(String str)
isIdCardNumberbool isIdCardNumber(String str)
isShortIdCardNumberbool isShortIdCardNumber(String str)
isUrlbool isUrl(String str)
isDomainbool isDomain(String str)
isValidAccountbool isValidAccount(String str)
isValidPasswordbool isValidPassword(String str)
isStrongPasswordbool isStrongPassword(String str)
isDatebool isDate(String str)
isValidXmlbool isValidXml(String str)
isBlankLinebool isBlankLine(String str)
isValidHtmlbool isValidHtml(String str)
isValidQQNumberbool isValidQQNumber(String str)
isValidPostCodebool isValidPostCode(String str)
isValidIPAddressbool isValidIPAddress(String str)
3
likes
90
pub points
47%
popularity

A dart library for lazier programmers. Functions are ported from kotlin.

Repository (GitHub)
View/report issues

Documentation

API reference

Uploader

rarnu1985@gmail.com

License

MIT (LICENSE)

Dependencies

convert, crypto

More

Packages that depend on dartkt