KTFlutter

A flutter library for lazier programmers.

Getting Started

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

dependencies:
    ... ...
    ktflutter: 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
_GLOBALkrunT krun<T>(T block())
krepeatkrepeat(int times, void action(int))
kalsoT kalso<T>(T t, void block(T obj))
kletR klet<T, R>(T t, R block(T obj))
platformplatform(void block(String s))call from native
appVersionCodeappVersionCode(void block(String s))call from native
appVersionNameappVersionName(void block(String s))call from native
deviceVersiondeviceVersion(void block(String s))call from native
deviceModeldeviceModel(void block(String s))call from native
deviceIddeviceId(void block(String s))call from native
appBundleappBundle(void block(String s))call from native, iOS only
appPackageappPackage(void block(String s))call from native, Android only
deviceDocumentPathdeviceDocumentPath(void block(String path))call from native
deviceFilePathdeviceFilePath(void block(String path))call from native
deviceCachePathdeviceCachePath(void block(String path))call from native
deviceExternalPathdeviceExternalPath(void block(String path))call from native, Android only
deviceExternalDocumentPathdeviceExternalDocumentPath(void block(String path))call from native, Android only
deviceExternalFilePathdeviceExternalFilePath(void block(String path))call from native, Android only
deviceExternalCachePathdeviceExternalCachePath(void block(String path))call from native, Android only
deviceObbPathdeviceObbPath(void block(String path))call from native, Android only
_ROUTErouteroute<T>(String name, dynamic arguments, void block(T obj))
routeListrouteList<T>(String name, dynamic arguments, void block(List<T> list))
routeMaprouteMap<K, V>(String name, dynamic arguments, void block(Map<K, V> map))
routeObjrouteObj<T>(String name, dynamic arguments, T parse(dynamic p), void block(T obj))
routeObjListrouteObjList<T>(String name, dynamic arguments, T parse(dynamic p), void block(List<T> list))
routeObjMaprouteObjMap<K, V>(String name, dynamic arguments, V parse(dynamic p), void block(Map<K, V> map))
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)
_TOASTtoasttoast(BuildContext context, String message, int duration = 2)
KFPairtoListKFList<T> toList()
KFStringstringOfKFString stringOf(String str)
alsoKFString also(void block(KFString s))
letR let<R>(R block(KFString s))
takeIfKFString takeIf(bool block(KFString s))
takeUnlessKFString takeUnless(bool block(KFString s))
substringBeforeKFString substringBefore(Pattern pattern)
substringAfterKFString substringAfter(Pattern pattern)
substringBeforeLastKFString substringBeforeLast(Pattern pattern)
substringAfterLastKFString substringAfterLast(Pattern pattern)
removeRangeKFString removeRange(int startIdx, int endIdx)
removePrefixKFString removePrefix(Pattern pattern)
removeSuffixKFString removeSuffix(Pattern pattern)
removeSurroundingKFString removeSurrounding(Pattern pattern)
replaceBeforeKFString replaceBefore(Pattern pattern, Object replacement)Object can be String/KFString
replaceAfterKFString replaceAfter(Pattern pattern, Object replacement)Object can be String/KFString
replaceAfterLastKFString replaceAfterLast(Pattern pattern, Object replacement)Object can be String/KFString
replaceBeforeLastKFString replaceBeforeLast(Pattern pattern, Object replacement)Object can be String/KFString
linesKFList<KFString> lines()
dropKFString drop(int n)
dropLastKFString dropLast(int n)
filterKFString filter(bool block(KFString str))
filterIndexedKFString filterIndexed(bool block(int idx, KFString str))
filterNotKFString filterNot(bool block(KFString str))
reversedKFString reversed()
toListKFList<KFString> toList()
mapKFList<T> map<T>(T block(KFString s))
mapIndexedKFList<T> mapIndexed<T>(T block(int idx, KFString s))
forEachforEach(void action(KFString s))
forEachIndexedforEachIndexed(void action(int idx, KFString s))
reduceKFString reduce(KFString oper(KFString acc, KFString s))
reduceIndexedKFString reduceIndexed(KFString oper(int idx, KFString acc, KFString s))
toIntint toInt()
toDoubledouble toDouble()
toBoolbool toBool()
base64encodeKFString base64encode()
base64decodeKFString base64decode()
toIntListKFList<int> toIntList()
lastPathPartKFString lastPathPart()
getPathDirectoryKFString getPathDirectory()
toJsonEncodedKFString toJsonEncoded()
toTitleUpperCaseKFString toTitleUpperCase()
appendPathPartKFString appendPathPart(Object part)Object can be String/KFString
extensionKFString extension()
replaceTagKFString replaceTag(String tag, KFString block())
skipEmptyLineKFString skipEmptyLine()
toPairKFPair<KFString, KFString> toPair()
savesave(File f)
asFileWriteTextFile asFileWriteText(Object s)Object can be String/KFString
asFileReadTextKFString asFileReadText()
asFileMkdirsasFileMkdirs()
asFileFile asFile()
KFList<E>listOfKFList<E> listOf<E>(Iterable<E> list)
toFlutterListList<E< toFlutterList()
alsoKFList<E> also(void block(KFList<E> list))
letR let<R>(R block(KFList<E> list))
takeIfKFList<E> takeIf(bool block(KFList<E> list))
takeUnlessKFList<E> takeUnless(bool block(KFList<E> list))
findE find(bool block(E obj))
findLastE findLast(bool block(E obj))
indexOfFirstint indexOfFirst(bool block(E obj))
indexOfLastint indexOfLast(bool block(E obj))
dropKFList<E> drop(int n)
dropLastKFList<E> dropLast(int n)
filterKFList<E> filter(bool block(E obj))
filterIndexedKFList<E> filterIndexed(bool block(int idx, E obj))
filterNotKFList<E> filterNot(bool block(E obj))
sliceKFList<E> slice(int startIdx, int endIdx)
sortByKFList<E> sortBy(int block(E first, E second))
sortByDescendingKFList<E> sortByDescending(int block(E first, E second))
mapKFList<T> map<T>(T block(E obj))overrided
mapIndexedKFList<T> mapIndexed<T>(T block(int idx, E obj))
distinctKFList<E> distinct()
distinctByKFList<E> distinctBy<K>(K block(E obj))
allbool all(bool block(E obj))
anybool any(bool block(E obj))
countint count(bool block(E obj))
forEachIndexedforEachIndexed(void action(int index, E element))
nonebool none(bool block(E obj))
reduceIndexedE reduceIndexed(E oper(int idx, E acc, E s))
minusminus(Object obj)Object can be List/KFList
joinToStringKFString joinToString(String sep = ",")
toStringListKFList<String> toStringList()
toMapKFMap<K, V> toMap<K, V>()
mapToC mapTo<R, C extends List<R>>(C dest, R block(E obj))
mapIndexedToC mapIndexedTo<R, C extends List<R>>(C dest, R block(int idx, E obj))
filterToC filterTo<C extends List<E>>(C dest, bool block(E obj))
filterIndexedToC filterIndexedTo<C extends List<E>>(C dest, bool block(int idx, E obj))
filterNotToC filterNotTo<C extends List<E>>(C dest, bool block(E obj))
KFSet<E>setOfKFSet<E> setOf<E>(Iterable<E> set)
alsoKFSet<E> also(void block(KFSet<E> list))
letR let<R>(R block(KFSet<E> list))
takeIfKFSet<E> takeIf(bool block(KFSet<E> list))
takeUnlessKFSet<E> takeUnless(bool block(KFSet<E> list))
findE find(bool block(E obj))
findLastE findLast(bool block(E obj))
indexOfFirstint indexOfFirst(bool block(E obj))
indexOfLastint indexOfLast(bool block(E obj))
dropKFSet<E> drop(int n)
dropLastKFSet<E> dropLast(int n)
filterKFSet<E> filter(bool block(E obj))
filterIndexedKFSet<E> filterIndexed(bool block(int idx, E obj))
filterNotKFSet<E> filterNot(bool block(E obj))
sliceKFSet<E> slice(int startIdx, int endIdx)
sortByKFSet<E> sortBy(int block(E first, E second))
sortByDescendingKFSet<E> sortByDescending(int block(E first, E second))
mapKFSet<T> map<T>(T block(E obj))overrided
mapIndexedKFSet<T> mapIndexed<T>(T block(int idx, E obj))
distinctKFSet<E> distinct()
distinctByKFSet<E> distinctBy<K>(K block(E obj))
allbool all(bool block(E obj))
anybool any(bool block(E obj))
countint count(bool block(E obj))
forEachIndexedforEachIndexed(void action(int index, E element))
nonebool none(bool block(E obj))
reduceIndexedE reduceIndexed(E oper(int idx, E acc, E s))
minusminus(Object obj)
joinToStringKFString joinToString(String sep = ",")
toStringListKFSet<String> toStringList()
toMapKFMap<K, V> toMap<K, V>()
mapToC mapTo<R, C extends Set<R>>(C dest, R block(E obj))
mapIndexedToC mapIndexedTo<R, C extends Set<R>>(C dest, R block(int idx, E obj))
filterToC filterTo<C extends Set<E>>(C dest, bool block(E obj))
filterIndexedToC filterIndexedTo<C extends Set<E>>(C dest, bool block(int idx, E obj))
filterNotToC filterNotTo<C extends Set<E>>(C dest, bool block(E obj))
KFMap<K, V>mapOfKFMap<K, V> mapOf<K, V6gt;(Map<K, V> map)
alsoKFMap<K, V> also(void block(KFMap<K, V> map))
letR let<R>(R block(KFMap<K, V> list))
takeIfKFMap<K, V> takeIf(bool block(KFMap<K, V> list))
takeUnlessKFMap<K, V> takeUnless(bool block(KFMap<K, V> list))
toListKFList<KFPair<K, V>> toList()
mapToListKFList<R> mapToList<R>(R block(MapEntry<K, V> e))
forEachEntryforEachEntry(void block(MapEntry<K, V> e))
allbool all(bool block(MapEntry<K, V> e))
anybool any(bool block(MapEntry<K, V> e))
countint count(bool block(MapEntry<K, V> e))
nonebool none(bool block(MapEntry<K, V> e))
filterKeysKFMap<K, V> filterKeys(bool block(K k))
filterValuesKFMap<K, V> filterValues(bool block(V v))
filterKFMap<K, V> filter(bool block(MapEntry<K, V> e))
filterNotKFMap<K, V> filterNot(bool block(MapEntry<K, V> e))
addadd(Object obj)Object can be Map/KFMap
minusminus(Object obj)Object can be Map/KFMap
filterToKFMap<K, V> filterTo<M extends Map<K, V>>(M dest, bool block(MapEntry<K, V> e))
filterNotToKFMap<K, V> filterNotTo<M extends Map<K, V>>(M dest, bool block(MapEntry<K, V> e))
filterKeysToKFMap<K, V> filterKeysTo<M extends Map<K, V>>(M dest, bool block(K k))
filterValuesToKFMap<K, V> filterValuesTo<M extends Map<K, V>>(M dest, bool block(V v))
mapToKFMap<K2, V2> mapTo<K2, V2, C extends Map<K2, V2>>(C dest, MapEntry<K2, V2> block(MapEntry<K, V> e))
mapToListToKFList<R> mapToListTo<R, C extends List<R>>(C dest, R block(MapEntry<K, V> e))
mapKeysToKFMap<K2, V2> mapKeysTo<K2, V2, C extends Map<K2, V2>>(C dest, MapEntry<K2, V2> block(K k))
mapKeysToListToKFList<R> mapKeysToListTo<R, C extends List<R>>(C dest, R block(K k))
mapValuesToKFMap<K2, V2> mapValuesTo<K2, V2, C extends Map<K2, V2>>(C dest, MapEntry<K2, V2> block(V v))
mapValuesToListToKFList<R> mapValuesToListTo<R, C extends List<R>>(C dest, R block(V v))
_REGEXPregexMatchbool regexMatch(String str, String regex)
isStringRegbool 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)
KMixin<T>alsoT also(void block(T obj))
letR let<R>(R block(T obj))
takeIfT takeIf(bool block(T obj))
takeUnlessT takeUnless(bool block(T obj))

example

You may visit example project for more about KTFlutter

Libraries

download_extension
global_extension
http_extension
ktflutter
list_extension
map_extension
pair_extension
regex_extension
route_extension
set_extension
string_extension
toast_extension