ktflutter 1.0.2 ktflutter: ^1.0.2 copied to clipboard
A flutter library for lazier programmers. Functions are ported from kotlin.
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:
Class | Method | Definition | Note |
---|---|---|---|
_GLOBAL | krun | T krun<T>(T block()) | |
krepeat | krepeat(int times, void action(int)) | ||
kalso | T kalso<T>(T t, void block(T obj)) | ||
klet | R klet<T, R>(T t, R block(T obj)) | ||
platform | platform(void block(String s)) | call from native | |
appVersionCode | appVersionCode(void block(String s)) | call from native | |
appVersionName | appVersionName(void block(String s)) | call from native | |
deviceVersion | deviceVersion(void block(String s)) | call from native | |
deviceModel | deviceModel(void block(String s)) | call from native | |
deviceId | deviceId(void block(String s)) | call from native | |
appBundle | appBundle(void block(String s)) | call from native, iOS only | |
appPackage | appPackage(void block(String s)) | call from native, Android only | |
deviceDocumentPath | deviceDocumentPath(void block(String path)) | call from native | |
deviceFilePath | deviceFilePath(void block(String path)) | call from native | |
deviceCachePath | deviceCachePath(void block(String path)) | call from native | |
deviceExternalPath | deviceExternalPath(void block(String path)) | call from native, Android only | |
deviceExternalDocumentPath | deviceExternalDocumentPath(void block(String path)) | call from native, Android only | |
deviceExternalFilePath | deviceExternalFilePath(void block(String path)) | call from native, Android only | |
deviceExternalCachePath | deviceExternalCachePath(void block(String path)) | call from native, Android only | |
deviceObbPath | deviceObbPath(void block(String path)) | call from native, Android only | |
_ROUTE | route | route<T>(String name, dynamic arguments, void block(T obj)) | |
routeList | routeList<T>(String name, dynamic arguments, void block(List<T> list)) | ||
routeMap | routeMap<K, V>(String name, dynamic arguments, void block(Map<K, V> map)) | ||
routeObj | routeObj<T>(String name, dynamic arguments, T parse(dynamic p), void block(T obj)) | ||
routeObjList | routeObjList<T>(String name, dynamic arguments, T parse(dynamic p), void block(List<T> list)) | ||
routeObjMap | routeObjMap<K, V>(String name, dynamic arguments, V parse(dynamic p), void block(Map<K, V> map)) | ||
HttpMethod | GET, HEAD, POST, PUT, DELETE | ||
HttpResponse | |||
HttpError | |||
_HTTP | http | Future<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}) | |
httpGet | Future<HttpResponse> httpGet(String url, {Map<String, String> param, Map<String, String> headers}) | ||
httpPost | Future<HttpResponse> httpPost(String url, {Map<String, String> param, String body, Map<String, String> headers}) | ||
DownloadState | Start, Progress, Complete, Error | ||
DownloadCallback | void Function(DownloadState state, int position, int filesize, String error) | ||
_ DOWNLOAD | download | Future<bool> download(String url, String localFile, DownloadCallback callback) | |
_TOAST | toast | toast(BuildContext context, String message, [int duration = 2]) | |
KFPair | toList | KFList<T> toList() | |
KFString | stringOf | KFString stringOf(String str) | |
also | KFString also(void block(KFString s)) | ||
let | R let<R>(R block(KFString s)) | ||
takeIf | KFString takeIf(bool block(KFString s)) | ||
takeUnless | KFString takeUnless(bool block(KFString s)) | ||
substringBefore | KFString substringBefore(Pattern pattern) | ||
substringAfter | KFString substringAfter(Pattern pattern) | ||
substringBeforeLast | KFString substringBeforeLast(Pattern pattern) | ||
substringAfterLast | KFString substringAfterLast(Pattern pattern) | ||
removeRange | KFString removeRange(int startIdx, int endIdx) | ||
removePrefix | KFString removePrefix(Pattern pattern) | ||
removeSuffix | KFString removeSuffix(Pattern pattern) | ||
removeSurrounding | KFString removeSurrounding(Pattern pattern) | ||
replaceBefore | KFString replaceBefore(Pattern pattern, Object replacement) | Object can be String/KFString | |
replaceAfter | KFString replaceAfter(Pattern pattern, Object replacement) | Object can be String/KFString | |
replaceAfterLast | KFString replaceAfterLast(Pattern pattern, Object replacement) | Object can be String/KFString | |
replaceBeforeLast | KFString replaceBeforeLast(Pattern pattern, Object replacement) | Object can be String/KFString | |
lines | KFList<KFString> lines() | ||
drop | KFString drop(int n) | ||
dropLast | KFString dropLast(int n) | ||
filter | KFString filter(bool block(KFString str)) | ||
filterIndexed | KFString filterIndexed(bool block(int idx, KFString str)) | ||
filterNot | KFString filterNot(bool block(KFString str)) | ||
reversed | KFString reversed() | ||
toList | KFList<KFString> toList() | ||
map | KFList<T> map<T>(T block(KFString s)) | ||
mapIndexed | KFList<T> mapIndexed<T>(T block(int idx, KFString s)) | ||
forEach | forEach(void action(KFString s)) | ||
forEachIndexed | forEachIndexed(void action(int idx, KFString s)) | ||
reduce | KFString reduce(KFString oper(KFString acc, KFString s)) | ||
reduceIndexed | KFString reduceIndexed(KFString oper(int idx, KFString acc, KFString s)) | ||
toInt | int toInt() | ||
toDouble | double toDouble() | ||
toBool | bool toBool() | ||
base64encode | KFString base64encode() | ||
base64decode | KFString base64decode() | ||
toIntList | KFList<int> toIntList() | ||
lastPathPart | KFString lastPathPart() | ||
getPathDirectory | KFString getPathDirectory() | ||
toJsonEncoded | KFString toJsonEncoded() | ||
toTitleUpperCase | KFString toTitleUpperCase() | ||
appendPathPart | KFString appendPathPart(Object part) | Object can be String/KFString | |
extension | KFString extension() | ||
replaceTag | KFString replaceTag(String tag, KFString block()) | ||
skipEmptyLine | KFString skipEmptyLine() | ||
toPair | KFPair<KFString, KFString> toPair() | ||
save | save(File f) | ||
asFileWriteText | File asFileWriteText(Object s) | Object can be String/KFString | |
asFileReadText | KFString asFileReadText() | ||
asFileMkdirs | asFileMkdirs() | ||
asFile | File asFile() | ||
KFList<E> | listOf | KFList<E> listOf<E>(Iterable<E> list) | |
toFlutterList | List<E< toFlutterList() | ||
also | KFList<E> also(void block(KFList<E> list)) | ||
let | R let<R>(R block(KFList<E> list)) | ||
takeIf | KFList<E> takeIf(bool block(KFList<E> list)) | ||
takeUnless | KFList<E> takeUnless(bool block(KFList<E> list)) | ||
find | E find(bool block(E obj)) | ||
findLast | E findLast(bool block(E obj)) | ||
indexOfFirst | int indexOfFirst(bool block(E obj)) | ||
indexOfLast | int indexOfLast(bool block(E obj)) | ||
drop | KFList<E> drop(int n) | ||
dropLast | KFList<E> dropLast(int n) | ||
filter | KFList<E> filter(bool block(E obj)) | ||
filterIndexed | KFList<E> filterIndexed(bool block(int idx, E obj)) | ||
filterNot | KFList<E> filterNot(bool block(E obj)) | ||
slice | KFList<E> slice(int startIdx, int endIdx) | ||
sortBy | KFList<E> sortBy(int block(E first, E second)) | ||
sortByDescending | KFList<E> sortByDescending(int block(E first, E second)) | ||
map | KFList<T> map<T>(T block(E obj)) | overrided | |
mapIndexed | KFList<T> mapIndexed<T>(T block(int idx, E obj)) | ||
distinct | KFList<E> distinct() | ||
distinctBy | KFList<E> distinctBy<K>(K block(E obj)) | ||
all | bool all(bool block(E obj)) | ||
any | bool any(bool block(E obj)) | ||
count | int count(bool block(E obj)) | ||
forEachIndexed | forEachIndexed(void action(int index, E element)) | ||
none | bool none(bool block(E obj)) | ||
reduceIndexed | E reduceIndexed(E oper(int idx, E acc, E s)) | ||
minus | minus(Object obj) | Object can be List/KFList | |
joinToString | KFString joinToString([String sep = ","]) | ||
toStringList | KFList<String> toStringList() | ||
toMap | KFMap<K, V> toMap<K, V>() | ||
mapTo | C mapTo<R, C extends List<R>>(C dest, R block(E obj)) | ||
mapIndexedTo | C mapIndexedTo<R, C extends List<R>>(C dest, R block(int idx, E obj)) | ||
filterTo | C filterTo<C extends List<E>>(C dest, bool block(E obj)) | ||
filterIndexedTo | C filterIndexedTo<C extends List<E>>(C dest, bool block(int idx, E obj)) | ||
filterNotTo | C filterNotTo<C extends List<E>>(C dest, bool block(E obj)) | ||
KFSet<E> | setOf | KFSet<E> setOf<E>(Iterable<E> set) | |
also | KFSet<E> also(void block(KFSet<E> list)) | ||
let | R let<R>(R block(KFSet<E> list)) | ||
takeIf | KFSet<E> takeIf(bool block(KFSet<E> list)) | ||
takeUnless | KFSet<E> takeUnless(bool block(KFSet<E> list)) | ||
find | E find(bool block(E obj)) | ||
findLast | E findLast(bool block(E obj)) | ||
indexOfFirst | int indexOfFirst(bool block(E obj)) | ||
indexOfLast | int indexOfLast(bool block(E obj)) | ||
drop | KFSet<E> drop(int n) | ||
dropLast | KFSet<E> dropLast(int n) | ||
filter | KFSet<E> filter(bool block(E obj)) | ||
filterIndexed | KFSet<E> filterIndexed(bool block(int idx, E obj)) | ||
filterNot | KFSet<E> filterNot(bool block(E obj)) | ||
slice | KFSet<E> slice(int startIdx, int endIdx) | ||
sortBy | KFSet<E> sortBy(int block(E first, E second)) | ||
sortByDescending | KFSet<E> sortByDescending(int block(E first, E second)) | ||
map | KFSet<T> map<T>(T block(E obj)) | overrided | |
mapIndexed | KFSet<T> mapIndexed<T>(T block(int idx, E obj)) | ||
distinct | KFSet<E> distinct() | ||
distinctBy | KFSet<E> distinctBy<K>(K block(E obj)) | ||
all | bool all(bool block(E obj)) | ||
any | bool any(bool block(E obj)) | ||
count | int count(bool block(E obj)) | ||
forEachIndexed | forEachIndexed(void action(int index, E element)) | ||
none | bool none(bool block(E obj)) | ||
reduceIndexed | E reduceIndexed(E oper(int idx, E acc, E s)) | ||
minus | minus(Object obj) | ||
joinToString | KFString joinToString([String sep = ","]) | ||
toStringList | KFSet<String> toStringList() | ||
toMap | KFMap<K, V> toMap<K, V>() | ||
mapTo | C mapTo<R, C extends Set<R>>(C dest, R block(E obj)) | ||
mapIndexedTo | C mapIndexedTo<R, C extends Set<R>>(C dest, R block(int idx, E obj)) | ||
filterTo | C filterTo<C extends Set<E>>(C dest, bool block(E obj)) | ||
filterIndexedTo | C filterIndexedTo<C extends Set<E>>(C dest, bool block(int idx, E obj)) | ||
filterNotTo | C filterNotTo<C extends Set<E>>(C dest, bool block(E obj)) | ||
KFMap<K, V> | mapOf | KFMap<K, V> mapOf<K, V6gt;(Map<K, V> map) | |
also | KFMap<K, V> also(void block(KFMap<K, V> map)) | ||
let | R let<R>(R block(KFMap<K, V> list)) | ||
takeIf | KFMap<K, V> takeIf(bool block(KFMap<K, V> list)) | ||
takeUnless | KFMap<K, V> takeUnless(bool block(KFMap<K, V> list)) | ||
toList | KFList<KFPair<K, V>> toList() | ||
mapToList | KFList<R> mapToList<R>(R block(MapEntry<K, V> e)) | ||
forEachEntry | forEachEntry(void block(MapEntry<K, V> e)) | ||
all | bool all(bool block(MapEntry<K, V> e)) | ||
any | bool any(bool block(MapEntry<K, V> e)) | ||
count | int count(bool block(MapEntry<K, V> e)) | ||
none | bool none(bool block(MapEntry<K, V> e)) | ||
filterKeys | KFMap<K, V> filterKeys(bool block(K k)) | ||
filterValues | KFMap<K, V> filterValues(bool block(V v)) | ||
filter | KFMap<K, V> filter(bool block(MapEntry<K, V> e)) | ||
filterNot | KFMap<K, V> filterNot(bool block(MapEntry<K, V> e)) | ||
add | add(Object obj) | Object can be Map/KFMap | |
minus | minus(Object obj) | Object can be Map/KFMap | |
filterTo | KFMap<K, V> filterTo<M extends Map<K, V>>(M dest, bool block(MapEntry<K, V> e)) | ||
filterNotTo | KFMap<K, V> filterNotTo<M extends Map<K, V>>(M dest, bool block(MapEntry<K, V> e)) | ||
filterKeysTo | KFMap<K, V> filterKeysTo<M extends Map<K, V>>(M dest, bool block(K k)) | ||
filterValuesTo | KFMap<K, V> filterValuesTo<M extends Map<K, V>>(M dest, bool block(V v)) | ||
mapTo | KFMap<K2, V2> mapTo<K2, V2, C extends Map<K2, V2>>(C dest, MapEntry<K2, V2> block(MapEntry<K, V> e)) | ||
mapToListTo | KFList<R> mapToListTo<R, C extends List<R>>(C dest, R block(MapEntry<K, V> e)) | ||
mapKeysTo | KFMap<K2, V2> mapKeysTo<K2, V2, C extends Map<K2, V2>>(C dest, MapEntry<K2, V2> block(K k)) | ||
mapKeysToListTo | KFList<R> mapKeysToListTo<R, C extends List<R>>(C dest, R block(K k)) | ||
mapValuesTo | KFMap<K2, V2> mapValuesTo<K2, V2, C extends Map<K2, V2>>(C dest, MapEntry<K2, V2> block(V v)) | ||
mapValuesToListTo | KFList<R> mapValuesToListTo<R, C extends List<R>>(C dest, R block(V v)) | ||
_REGEXP | regexMatch | bool regexMatch(String str, String regex) | |
isStringReg | bool isStringReg(String str, int type) | ||
isNumberReg | bool isNumberReg(String str, int type) | ||
isEmail | bool isEmail(String str) | ||
isPhoneNumber | bool isPhoneNumber(String str) | ||
isCellPhoneNumber | bool isCellPhoneNumber(String str) | ||
isChinesePhoneNumber | bool isChinesePhoneNumber(String str) | ||
isIdCardNumber | bool isIdCardNumber(String str) | ||
isShortIdCardNumber | bool isShortIdCardNumber(String str) | ||
isUrl | bool isUrl(String str) | ||
isDomain | bool isDomain(String str) | ||
isValidAccount | bool isValidAccount(String str) | ||
isValidPassword | bool isValidPassword(String str) | ||
isStrongPassword | bool isStrongPassword(String str) | ||
isDate | bool isDate(String str) | ||
isValidXml | bool isValidXml(String str) | ||
isBlankLine | bool isBlankLine(String str) | ||
isValidHtml | bool isValidHtml(String str) | ||
isValidQQNumber | bool isValidQQNumber(String str) | ||
isValidPostCode | bool isValidPostCode(String str) | ||
isValidIPAddress | bool isValidIPAddress(String str) | ||
KMixin<T> | also | T also(void block(T obj)) | |
let | R let<R>(R block(T obj)) | ||
takeIf | T takeIf(bool block(T obj)) | ||
takeUnless | T takeUnless(bool block(T obj)) | ||
example #
You may visit example
project for more about KTFlutter