├── .gitignore ├── CHANGELOG.md ├── LICENSE ├── README.md ├── android ├── .gitignore ├── build.gradle ├── gradle.properties ├── settings.gradle └── src │ └── main │ ├── AndroidManifest.xml │ └── kotlin │ └── com │ └── rarnu │ └── ktflutter │ └── KtflutterPlugin.kt ├── example ├── .gitignore ├── .metadata ├── README.md ├── android │ ├── app │ │ ├── build.gradle │ │ └── src │ │ │ ├── debug │ │ │ └── AndroidManifest.xml │ │ │ ├── main │ │ │ ├── AndroidManifest.xml │ │ │ ├── kotlin │ │ │ │ └── com │ │ │ │ │ └── example │ │ │ │ │ └── ktflutter_example │ │ │ │ │ └── MainActivity.kt │ │ │ └── res │ │ │ │ ├── drawable │ │ │ │ └── launch_background.xml │ │ │ │ ├── mipmap-hdpi │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-mdpi │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-xhdpi │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-xxhdpi │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-xxxhdpi │ │ │ │ └── ic_launcher.png │ │ │ │ └── values │ │ │ │ └── styles.xml │ │ │ └── profile │ │ │ └── AndroidManifest.xml │ ├── build.gradle │ ├── gradle.properties │ ├── gradle │ │ └── wrapper │ │ │ └── gradle-wrapper.properties │ └── settings.gradle ├── ios │ ├── Flutter │ │ ├── AppFrameworkInfo.plist │ │ ├── Debug.xcconfig │ │ └── Release.xcconfig │ ├── Podfile │ ├── Podfile.lock │ ├── Runner.xcodeproj │ │ ├── project.pbxproj │ │ ├── project.xcworkspace │ │ │ └── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ └── Runner.xcscheme │ ├── Runner.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ └── Runner │ │ ├── AppDelegate.swift │ │ ├── Assets.xcassets │ │ ├── AppIcon.appiconset │ │ │ ├── Contents.json │ │ │ ├── Icon-App-1024x1024@1x.png │ │ │ ├── Icon-App-20x20@1x.png │ │ │ ├── Icon-App-20x20@2x.png │ │ │ ├── Icon-App-20x20@3x.png │ │ │ ├── Icon-App-29x29@1x.png │ │ │ ├── Icon-App-29x29@2x.png │ │ │ ├── Icon-App-29x29@3x.png │ │ │ ├── Icon-App-40x40@1x.png │ │ │ ├── Icon-App-40x40@2x.png │ │ │ ├── Icon-App-40x40@3x.png │ │ │ ├── Icon-App-60x60@2x.png │ │ │ ├── Icon-App-60x60@3x.png │ │ │ ├── Icon-App-76x76@1x.png │ │ │ ├── Icon-App-76x76@2x.png │ │ │ └── Icon-App-83.5x83.5@2x.png │ │ └── LaunchImage.imageset │ │ │ ├── Contents.json │ │ │ ├── LaunchImage.png │ │ │ ├── LaunchImage@2x.png │ │ │ ├── LaunchImage@3x.png │ │ │ └── README.md │ │ ├── Base.lproj │ │ ├── LaunchScreen.storyboard │ │ └── Main.storyboard │ │ ├── Info.plist │ │ └── Runner-Bridging-Header.h ├── lib │ └── main.dart ├── pubspec.lock ├── pubspec.yaml └── test │ └── widget_test.dart ├── ios ├── .gitignore ├── Assets │ └── .gitkeep ├── Classes │ ├── KtflutterPlugin.h │ ├── KtflutterPlugin.m │ └── SwiftKtflutterPlugin.swift └── ktflutter.podspec ├── ktflutter.iml ├── lib ├── download_extension.dart ├── global_extension.dart ├── http_extension.dart ├── ktflutter.dart ├── list_extension.dart ├── map_extension.dart ├── pair_extension.dart ├── regex_extension.dart ├── route_extension.dart ├── set_extension.dart ├── string_extension.dart └── toast_extension.dart ├── pubspec.lock ├── pubspec.yaml └── test ├── ktflutter_http_test.dart └── ktflutter_test.dart /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .dart_tool/ 3 | 4 | .packages 5 | .pub/ 6 | 7 | build/ 8 | .vscode/ 9 | .idea/ 10 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 1.0.2 2 | 3 | * re-format code 4 | 5 | ## 1.0.0 6 | 7 | * release 8 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 CodeMonarch 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # KTFlutter 2 | 3 | A flutter library for lazier programmers. 4 | 5 | ## Getting Started 6 | 7 | Add dependence of ```KTFlutter``` to your project. The last version is ```1.0.2``` . 8 | 9 | ``` 10 | dependencies: 11 | ... ... 12 | ktflutter: 1.0.2 13 | ``` 14 | 15 | ## Functions 16 | 17 | Functions in the library are ported from kotlin, also included some useful utils like http. 18 | 19 | Here is a list for cognition: 20 | 21 | | Class | Method | Definition | Note | 22 | | :-- | :-- | :-- | :-- | 23 | | _GLOBAL | krun | T krun<T>(T block()) | | 24 | | | krepeat | krepeat(int times, void action(int)) | | 25 | | | kalso | T kalso<T>(T t, void block(T obj)) | | 26 | | | klet | R klet<T, R>(T t, R block(T obj)) | | 27 | | | platform | platform(void block(String s)) | call from native | 28 | | | appVersionCode | appVersionCode(void block(String s)) | call from native | 29 | | | appVersionName | appVersionName(void block(String s)) | call from native | 30 | | | deviceVersion | deviceVersion(void block(String s)) | call from native | 31 | | | deviceModel | deviceModel(void block(String s)) | call from native | 32 | | | deviceId | deviceId(void block(String s)) | call from native | 33 | | | appBundle | appBundle(void block(String s)) | call from native, iOS only | 34 | | | appPackage | appPackage(void block(String s)) | call from native, Android only | 35 | | | deviceDocumentPath | deviceDocumentPath(void block(String path)) | call from native | 36 | | | deviceFilePath | deviceFilePath(void block(String path)) | call from native | 37 | | | deviceCachePath | deviceCachePath(void block(String path)) | call from native | 38 | | | deviceExternalPath | deviceExternalPath(void block(String path)) | call from native, Android only | 39 | | | deviceExternalDocumentPath | deviceExternalDocumentPath(void block(String path)) | call from native, Android only | 40 | | | deviceExternalFilePath | deviceExternalFilePath(void block(String path)) | call from native, Android only | 41 | | | deviceExternalCachePath | deviceExternalCachePath(void block(String path)) | call from native, Android only | 42 | | | deviceObbPath | deviceObbPath(void block(String path)) | call from native, Android only | 43 | | _ROUTE | route | route<T>(String name, dynamic arguments, void block(T obj)) | | 44 | | | routeList | routeList<T>(String name, dynamic arguments, void block(List<T> list)) | | 45 | | | routeMap | routeMap<K, V>(String name, dynamic arguments, void block(Map<K, V> map)) | | 46 | | | routeObj | routeObj<T>(String name, dynamic arguments, T parse(dynamic p), void block(T obj)) | | 47 | | | routeObjList | routeObjList<T>(String name, dynamic arguments, T parse(dynamic p), void block(List<T> list)) | | 48 | | | routeObjMap | routeObjMap<K, V>(String name, dynamic arguments, V parse(dynamic p), void block(Map<K, V> map)) | | 49 | | HttpMethod | | GET, HEAD, POST, PUT, DELETE | | 50 | | HttpResponse | | | | 51 | | HttpError | | | | 52 | | _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}) | | 53 | | | httpGet | Future<HttpResponse> httpGet(String url, {Map<String, String> param, Map<String, String> headers}) | | 54 | | | httpPost | Future<HttpResponse> httpPost(String url, {Map<String, String> param, String body, Map<String, String> headers}) | | 55 | | DownloadState | | Start, Progress, Complete, Error | | 56 | | DownloadCallback | | void Function(DownloadState state, int position, int filesize, String error) | | 57 | | _ DOWNLOAD| download | Future<bool> download(String url, String localFile, DownloadCallback callback) | | 58 | | _TOAST | toast | toast(BuildContext context, String message, [int duration = 2]) | | 59 | | KFPair | toList | KFList<T> toList() | | 60 | | KFString | stringOf | KFString stringOf(String str) | | 61 | | | also | KFString also(void block(KFString s)) | | 62 | | | let | R let<R>(R block(KFString s)) | | 63 | | | takeIf | KFString takeIf(bool block(KFString s)) | | 64 | | | takeUnless | KFString takeUnless(bool block(KFString s)) | | 65 | | | substringBefore | KFString substringBefore(Pattern pattern) | | 66 | | | substringAfter | KFString substringAfter(Pattern pattern) | | 67 | | | substringBeforeLast | KFString substringBeforeLast(Pattern pattern) | | 68 | | | substringAfterLast | KFString substringAfterLast(Pattern pattern) | | 69 | | | removeRange | KFString removeRange(int startIdx, int endIdx) | | 70 | | | removePrefix | KFString removePrefix(Pattern pattern) | | 71 | | | removeSuffix | KFString removeSuffix(Pattern pattern) | | 72 | | | removeSurrounding | KFString removeSurrounding(Pattern pattern) | | 73 | | | replaceBefore | KFString replaceBefore(Pattern pattern, Object replacement) | Object can be String/KFString | 74 | | | replaceAfter | KFString replaceAfter(Pattern pattern, Object replacement) | Object can be String/KFString | 75 | | | replaceAfterLast | KFString replaceAfterLast(Pattern pattern, Object replacement) | Object can be String/KFString | 76 | | | replaceBeforeLast | KFString replaceBeforeLast(Pattern pattern, Object replacement) | Object can be String/KFString | 77 | | | lines | KFList<KFString> lines() | | 78 | | | drop | KFString drop(int n) | | 79 | | | dropLast | KFString dropLast(int n) | | 80 | | | filter | KFString filter(bool block(KFString str)) | | 81 | | | filterIndexed | KFString filterIndexed(bool block(int idx, KFString str)) | | 82 | | | filterNot | KFString filterNot(bool block(KFString str)) | | 83 | | | reversed | KFString reversed() | | 84 | | | toList | KFList<KFString> toList() | | 85 | | | map | KFList<T> map<T>(T block(KFString s)) | | 86 | | | mapIndexed | KFList<T> mapIndexed<T>(T block(int idx, KFString s)) | | 87 | | | forEach | forEach(void action(KFString s)) | | 88 | | | forEachIndexed | forEachIndexed(void action(int idx, KFString s)) | | 89 | | | reduce | KFString reduce(KFString oper(KFString acc, KFString s)) | | 90 | | | reduceIndexed | KFString reduceIndexed(KFString oper(int idx, KFString acc, KFString s)) | | 91 | | | toInt | int toInt() | | 92 | | | toDouble | double toDouble() | | 93 | | | toBool | bool toBool() | | 94 | | | base64encode | KFString base64encode() | | 95 | | | base64decode | KFString base64decode() | | 96 | | | toIntList | KFList<int> toIntList() | | 97 | | | lastPathPart | KFString lastPathPart() | | 98 | | | getPathDirectory | KFString getPathDirectory() | | 99 | | | toJsonEncoded | KFString toJsonEncoded() | | 100 | | | toTitleUpperCase | KFString toTitleUpperCase() | | 101 | | | appendPathPart | KFString appendPathPart(Object part) | Object can be String/KFString | 102 | | | extension | KFString extension() | | 103 | | | replaceTag | KFString replaceTag(String tag, KFString block()) | | 104 | | | skipEmptyLine | KFString skipEmptyLine() | | 105 | | | toPair | KFPair<KFString, KFString> toPair() | | 106 | | | save | save(File f) | | 107 | | | asFileWriteText | File asFileWriteText(Object s) | Object can be String/KFString | 108 | | | asFileReadText | KFString asFileReadText() | | 109 | | | asFileMkdirs | asFileMkdirs() | | 110 | | | asFile | File asFile() | | 111 | | KFList<E> | listOf | KFList<E> listOf<E>(Iterable<E> list) | | 112 | | | toFlutterList | List<E< toFlutterList() | | 113 | | | also | KFList<E> also(void block(KFList<E> list)) | | 114 | | | let | R let<R>(R block(KFList<E> list)) | | 115 | | | takeIf | KFList<E> takeIf(bool block(KFList<E> list)) | | 116 | | | takeUnless | KFList<E> takeUnless(bool block(KFList<E> list)) | | 117 | | | find | E find(bool block(E obj)) | | 118 | | | findLast | E findLast(bool block(E obj)) | | 119 | | | indexOfFirst | int indexOfFirst(bool block(E obj)) | | 120 | | | indexOfLast | int indexOfLast(bool block(E obj)) | | 121 | | | drop | KFList<E> drop(int n) | | 122 | | | dropLast | KFList<E> dropLast(int n) | | 123 | | | filter | KFList<E> filter(bool block(E obj)) | | 124 | | | filterIndexed | KFList<E> filterIndexed(bool block(int idx, E obj)) | | 125 | | | filterNot | KFList<E> filterNot(bool block(E obj)) | | 126 | | | slice | KFList<E> slice(int startIdx, int endIdx) | | 127 | | | sortBy | KFList<E> sortBy(int block(E first, E second)) | | 128 | | | sortByDescending | KFList<E> sortByDescending(int block(E first, E second)) | | 129 | | | map | KFList<T> map<T>(T block(E obj)) | overrided | 130 | | | mapIndexed | KFList<T> mapIndexed<T>(T block(int idx, E obj)) | | 131 | | | distinct | KFList<E> distinct() | | 132 | | | distinctBy | KFList<E> distinctBy<K>(K block(E obj)) | | 133 | | | all | bool all(bool block(E obj)) | | 134 | | | any | bool any(bool block(E obj)) | | 135 | | | count | int count(bool block(E obj)) | | 136 | | | forEachIndexed | forEachIndexed(void action(int index, E element)) | | 137 | | | none | bool none(bool block(E obj)) | | 138 | | | reduceIndexed | E reduceIndexed(E oper(int idx, E acc, E s)) | | 139 | | | minus | minus(Object obj) | Object can be List/KFList | 140 | | | joinToString | KFString joinToString([String sep = ","]) | | 141 | | | toStringList | KFList<String> toStringList() | | 142 | | | toMap | KFMap<K, V> toMap<K, V>() | | 143 | | | mapTo | C mapTo<R, C extends List<R>>(C dest, R block(E obj)) | | 144 | | | mapIndexedTo | C mapIndexedTo<R, C extends List<R>>(C dest, R block(int idx, E obj)) | | 145 | | | filterTo | C filterTo<C extends List<E>>(C dest, bool block(E obj)) | | 146 | | | filterIndexedTo | C filterIndexedTo<C extends List<E>>(C dest, bool block(int idx, E obj)) | | 147 | | | filterNotTo | C filterNotTo<C extends List<E>>(C dest, bool block(E obj)) | | 148 | | KFSet<E> | setOf | KFSet<E> setOf<E>(Iterable<E> set) | | 149 | | | also | KFSet<E> also(void block(KFSet<E> list)) | | 150 | | | let | R let<R>(R block(KFSet<E> list)) | | 151 | | | takeIf | KFSet<E> takeIf(bool block(KFSet<E> list)) | | 152 | | | takeUnless | KFSet<E> takeUnless(bool block(KFSet<E> list)) | | 153 | | | find | E find(bool block(E obj)) | | 154 | | | findLast | E findLast(bool block(E obj)) | | 155 | | | indexOfFirst | int indexOfFirst(bool block(E obj)) | | 156 | | | indexOfLast | int indexOfLast(bool block(E obj)) | | 157 | | | drop | KFSet<E> drop(int n) | | 158 | | | dropLast | KFSet<E> dropLast(int n) | | 159 | | | filter | KFSet<E> filter(bool block(E obj)) | | 160 | | | filterIndexed | KFSet<E> filterIndexed(bool block(int idx, E obj)) | | 161 | | | filterNot | KFSet<E> filterNot(bool block(E obj)) | | 162 | | | slice | KFSet<E> slice(int startIdx, int endIdx) | | 163 | | | sortBy | KFSet<E> sortBy(int block(E first, E second)) | | 164 | | | sortByDescending | KFSet<E> sortByDescending(int block(E first, E second)) | | 165 | | | map | KFSet<T> map<T>(T block(E obj)) | overrided | 166 | | | mapIndexed | KFSet<T> mapIndexed<T>(T block(int idx, E obj)) | | 167 | | | distinct | KFSet<E> distinct() | | 168 | | | distinctBy | KFSet<E> distinctBy<K>(K block(E obj)) | | 169 | | | all | bool all(bool block(E obj)) | | 170 | | | any | bool any(bool block(E obj)) | | 171 | | | count | int count(bool block(E obj)) | | 172 | | | forEachIndexed | forEachIndexed(void action(int index, E element)) | | 173 | | | none | bool none(bool block(E obj)) | | 174 | | | reduceIndexed | E reduceIndexed(E oper(int idx, E acc, E s)) | | 175 | | | minus | minus(Object obj) | | 176 | | | joinToString | KFString joinToString([String sep = ","]) | | 177 | | | toStringList | KFSet<String> toStringList() | | 178 | | | toMap | KFMap<K, V> toMap<K, V>() | | 179 | | | mapTo | C mapTo<R, C extends Set<R>>(C dest, R block(E obj)) | | 180 | | | mapIndexedTo | C mapIndexedTo<R, C extends Set<R>>(C dest, R block(int idx, E obj)) | | 181 | | | filterTo | C filterTo<C extends Set<E>>(C dest, bool block(E obj)) | | 182 | | | filterIndexedTo | C filterIndexedTo<C extends Set<E>>(C dest, bool block(int idx, E obj)) | | 183 | | | filterNotTo | C filterNotTo<C extends Set<E>>(C dest, bool block(E obj)) | | 184 | | KFMap<K, V> | mapOf | KFMap<K, V> mapOf<K, V6gt;(Map<K, V> map) | | 185 | | | also | KFMap<K, V> also(void block(KFMap<K, V> map)) | | 186 | | | let | R let<R>(R block(KFMap<K, V> list)) | | 187 | | | takeIf | KFMap<K, V> takeIf(bool block(KFMap<K, V> list)) | | 188 | | | takeUnless | KFMap<K, V> takeUnless(bool block(KFMap<K, V> list)) | | 189 | | | toList | KFList<KFPair<K, V>> toList() | | 190 | | | mapToList | KFList<R> mapToList<R>(R block(MapEntry<K, V> e))| | 191 | | | forEachEntry | forEachEntry(void block(MapEntry<K, V> e)) | | 192 | | | all | bool all(bool block(MapEntry<K, V> e)) | | 193 | | | any | bool any(bool block(MapEntry<K, V> e)) | | 194 | | | count | int count(bool block(MapEntry<K, V> e)) | | 195 | | | none | bool none(bool block(MapEntry<K, V> e)) | | 196 | | | filterKeys | KFMap<K, V> filterKeys(bool block(K k)) | | 197 | | | filterValues | KFMap<K, V> filterValues(bool block(V v)) | | 198 | | | filter | KFMap<K, V> filter(bool block(MapEntry<K, V> e)) | | 199 | | | filterNot | KFMap<K, V> filterNot(bool block(MapEntry<K, V> e)) | | 200 | | | add | add(Object obj) | Object can be Map/KFMap | 201 | | | minus | minus(Object obj) | Object can be Map/KFMap | 202 | | | filterTo | KFMap<K, V> filterTo<M extends Map<K, V>>(M dest, bool block(MapEntry<K, V> e)) | | 203 | | | filterNotTo | KFMap<K, V> filterNotTo<M extends Map<K, V>>(M dest, bool block(MapEntry<K, V> e)) | | 204 | | | filterKeysTo | KFMap<K, V> filterKeysTo<M extends Map<K, V>>(M dest, bool block(K k)) | | 205 | | | filterValuesTo | KFMap<K, V> filterValuesTo<M extends Map<K, V>>(M dest, bool block(V v)) | | 206 | | | mapTo | KFMap<K2, V2> mapTo<K2, V2, C extends Map<K2, V2>>(C dest, MapEntry<K2, V2> block(MapEntry<K, V> e)) | | 207 | | | mapToListTo | KFList<R> mapToListTo<R, C extends List<R>>(C dest, R block(MapEntry<K, V> e)) | | 208 | | | mapKeysTo | KFMap<K2, V2> mapKeysTo<K2, V2, C extends Map<K2, V2>>(C dest, MapEntry<K2, V2> block(K k)) | | 209 | | | mapKeysToListTo | KFList<R> mapKeysToListTo<R, C extends List<R>>(C dest, R block(K k)) | | 210 | | | mapValuesTo | KFMap<K2, V2> mapValuesTo<K2, V2, C extends Map<K2, V2>>(C dest, MapEntry<K2, V2> block(V v)) | | 211 | | | mapValuesToListTo | KFList<R> mapValuesToListTo<R, C extends List<R>>(C dest, R block(V v)) | | 212 | | _REGEXP | regexMatch | bool regexMatch(String str, String regex) | | 213 | | | isStringReg | bool isStringReg(String str, int type) | | 214 | | | isNumberReg | bool isNumberReg(String str, int type) | | 215 | | | isEmail | bool isEmail(String str) | | 216 | | | isPhoneNumber | bool isPhoneNumber(String str) | | 217 | | | isCellPhoneNumber | bool isCellPhoneNumber(String str) | | 218 | | | isChinesePhoneNumber | bool isChinesePhoneNumber(String str) | | 219 | | | isIdCardNumber | bool isIdCardNumber(String str) | | 220 | | | isShortIdCardNumber | bool isShortIdCardNumber(String str) | | 221 | | | isUrl | bool isUrl(String str) | | 222 | | | isDomain | bool isDomain(String str) | | 223 | | | isValidAccount | bool isValidAccount(String str) | | 224 | | | isValidPassword | bool isValidPassword(String str) | | 225 | | | isStrongPassword | bool isStrongPassword(String str) | | 226 | | | isDate | bool isDate(String str) | | 227 | | | isValidXml | bool isValidXml(String str) | | 228 | | | isBlankLine | bool isBlankLine(String str) | | 229 | | | isValidHtml | bool isValidHtml(String str) | | 230 | | | isValidQQNumber | bool isValidQQNumber(String str) | | 231 | | | isValidPostCode | bool isValidPostCode(String str) | | 232 | | | isValidIPAddress | bool isValidIPAddress(String str) | | 233 | | KMixin<T> | also | T also(void block(T obj)) | | 234 | | | let | R let<R>(R block(T obj)) | | 235 | | | takeIf | T takeIf(bool block(T obj)) | | 236 | | | takeUnless | T takeUnless(bool block(T obj)) | | 237 | | | | | | 238 | 239 | ## example 240 | 241 | You may visit ```example``` project for more about ```KTFlutter``` -------------------------------------------------------------------------------- /android/.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | -------------------------------------------------------------------------------- /android/build.gradle: -------------------------------------------------------------------------------- 1 | group 'com.example.ktflutter' 2 | version '1.0-SNAPSHOT' 3 | 4 | buildscript { 5 | ext.kotlin_version = '1.2.71' 6 | repositories { 7 | google() 8 | jcenter() 9 | } 10 | 11 | dependencies { 12 | classpath 'com.android.tools.build:gradle:3.2.1' 13 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 14 | } 15 | } 16 | 17 | rootProject.allprojects { 18 | repositories { 19 | google() 20 | jcenter() 21 | } 22 | } 23 | 24 | apply plugin: 'com.android.library' 25 | apply plugin: 'kotlin-android' 26 | 27 | android { 28 | compileSdkVersion 28 29 | 30 | sourceSets { 31 | main.java.srcDirs += 'src/main/kotlin' 32 | } 33 | defaultConfig { 34 | minSdkVersion 16 35 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 36 | } 37 | lintOptions { 38 | disable 'InvalidPackage' 39 | } 40 | } 41 | 42 | dependencies { 43 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" 44 | } 45 | -------------------------------------------------------------------------------- /android/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx1536M 2 | 3 | -------------------------------------------------------------------------------- /android/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'ktflutter' 2 | -------------------------------------------------------------------------------- /android/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | -------------------------------------------------------------------------------- /android/src/main/kotlin/com/rarnu/ktflutter/KtflutterPlugin.kt: -------------------------------------------------------------------------------- 1 | @file:Suppress("DEPRECATION") 2 | 3 | package com.rarnu.ktflutter 4 | 5 | import android.content.Context 6 | import android.os.Build 7 | import android.os.Environment 8 | import android.provider.Settings 9 | import io.flutter.plugin.common.MethodChannel 10 | import io.flutter.plugin.common.PluginRegistry 11 | import java.io.File 12 | 13 | fun nativeRouting(block: KtflutterPlugin.() -> Unit) { 14 | block(KtflutterPlugin) 15 | } 16 | 17 | /* 18 | deviceDocumentPath(void block(String path)) async => block(await posix.invokeMethod("device_document_path", {})); 19 | deviceFilePath(void block(String path)) async => block(await posix.invokeMethod("device_file_path", {})); 20 | deviceCachePath(void block(String path)) async => block(await posix.invokeMethod("device_cache_path", {})); 21 | 22 | // android only 23 | deviceExternalPath(void block(String path)) => platform((p) async { 24 | block(p == "Android" ? (await posix.invokeMethod("device_external_path", {})) : ""); 25 | }); 26 | 27 | */ 28 | 29 | object KtflutterPlugin { 30 | private const val channelName = "com.rarnu.flutter/routing" 31 | private val channelList = mutableMapOf) -> Any?>() 32 | 33 | @JvmStatic 34 | fun registerWith(registrar: PluginRegistry.Registrar) { 35 | MethodChannel(registrar.messenger(), channelName).setMethodCallHandler { call, result -> 36 | when(call.method) { 37 | "platform" -> result.success("Android") 38 | "app_version_code" -> result.success(with(registrar.context()) { packageManager.getPackageInfo(packageName, 0).versionCode.toString() }) 39 | "app_version_name" -> result.success(with(registrar.context()) { packageManager.getPackageInfo(packageName, 0).versionName }) 40 | "app_package" -> result.success(registrar.context().packageName) 41 | "device_version" -> result.success(Build.VERSION.SDK_INT.toString()) 42 | "device_model" -> result.success(Build.MODEL) 43 | "device_id" -> result.success(Settings.Secure.getString(registrar.context().contentResolver, Settings.Secure.ANDROID_ID)) 44 | // paths 45 | "device_document_path" -> result.success(registrar.context().filesDir.absolutePath.substringBeforeLast("/")) 46 | "device_file_path"-> result.success(registrar.context().filesDir.absolutePath.also { with(File(it)) { if (!exists()) mkdirs() } }) 47 | "device_cache_path" -> result.success(registrar.context().cacheDir.absolutePath.also { with(File(it)) { if (!exists()) mkdirs() } }) 48 | // android only paths 49 | "device_external_path" -> result.success(Environment.getExternalStorageDirectory().absolutePath) 50 | "device_external_document_path" -> result.success(registrar.context().getExternalFilesDir("")?.absolutePath?.substringBeforeLast("/")) 51 | "device_external_file_path" -> result.success(registrar.context().getExternalFilesDir("")?.absolutePath.also { with(File(it)) { if (!exists()) mkdirs() } }) 52 | "device_external_cache_path" -> result.success(registrar.context().externalCacheDir?.absolutePath.also { with(File(it)) { if (!exists()) mkdirs() } }) 53 | "device_obb_path" -> result.success(registrar.context().obbDir?.absolutePath.also { with(File(it)) { if (!exists()) mkdirs() } }) 54 | 55 | else -> { 56 | val m = channelList[call.method] 57 | if (m != null) { 58 | val ret = m(registrar.context(), call.arguments as Map) 59 | result.success(if (ret is Unit) null else ret) 60 | } else { 61 | result.success(null) 62 | } 63 | } 64 | } 65 | } 66 | } 67 | 68 | fun route(name: String, block:(ctx: Context, params: Map) -> Any?) { 69 | channelList[name] = block 70 | } 71 | fun routeList(name: String, block:(ctx: Context, params: Map) -> List?) { 72 | channelList[name] = block 73 | } 74 | fun routeMap(name: String, block:(ctx: Context, params: Map) -> Map?) { 75 | channelList[name] = block 76 | } 77 | fun routeObj(name: String, block:(ctx: Context, params: Map) -> Map?) { 78 | channelList[name] = block 79 | } 80 | fun routeObjList(name: String, block:(ctx: Context, params: Map) -> List>?) { 81 | channelList[name] = block 82 | } 83 | 84 | fun routeObjMap(name: String, block:(ctx: Context, params: Map) -> Map>?) { 85 | channelList[name] = block 86 | } 87 | 88 | } 89 | -------------------------------------------------------------------------------- /example/.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .buildlog/ 9 | .history 10 | .svn/ 11 | 12 | # IntelliJ related 13 | *.iml 14 | *.ipr 15 | *.iws 16 | .idea/ 17 | 18 | # The .vscode folder contains launch configuration and tasks you configure in 19 | # VS Code which you may wish to be included in version control, so this line 20 | # is commented out by default. 21 | #.vscode/ 22 | 23 | # Flutter/Dart/Pub related 24 | **/doc/api/ 25 | .dart_tool/ 26 | .flutter-plugins 27 | .packages 28 | .pub-cache/ 29 | .pub/ 30 | /build/ 31 | 32 | # Android related 33 | **/android/**/gradle-wrapper.jar 34 | **/android/.gradle 35 | **/android/captures/ 36 | **/android/gradlew 37 | **/android/gradlew.bat 38 | **/android/local.properties 39 | **/android/**/GeneratedPluginRegistrant.java 40 | 41 | # iOS/XCode related 42 | **/ios/**/*.mode1v3 43 | **/ios/**/*.mode2v3 44 | **/ios/**/*.moved-aside 45 | **/ios/**/*.pbxuser 46 | **/ios/**/*.perspectivev3 47 | **/ios/**/*sync/ 48 | **/ios/**/.sconsign.dblite 49 | **/ios/**/.tags* 50 | **/ios/**/.vagrant/ 51 | **/ios/**/DerivedData/ 52 | **/ios/**/Icon? 53 | **/ios/**/Pods/ 54 | **/ios/**/.symlinks/ 55 | **/ios/**/profile 56 | **/ios/**/xcuserdata 57 | **/ios/.generated/ 58 | **/ios/Flutter/App.framework 59 | **/ios/Flutter/Flutter.framework 60 | **/ios/Flutter/Generated.xcconfig 61 | **/ios/Flutter/app.flx 62 | **/ios/Flutter/app.zip 63 | **/ios/Flutter/flutter_assets/ 64 | **/ios/ServiceDefinitions.json 65 | **/ios/Runner/GeneratedPluginRegistrant.* 66 | 67 | # Exceptions to above rules. 68 | !**/ios/**/default.mode1v3 69 | !**/ios/**/default.mode2v3 70 | !**/ios/**/default.pbxuser 71 | !**/ios/**/default.perspectivev3 72 | !/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages 73 | -------------------------------------------------------------------------------- /example/.metadata: -------------------------------------------------------------------------------- 1 | # This file tracks properties of this Flutter project. 2 | # Used by Flutter tool to assess capabilities and perform upgrades etc. 3 | # 4 | # This file should be version controlled and should not be manually edited. 5 | 6 | version: 7 | revision: 95ca76897655767a8db0c5e843d7195072218c17 8 | channel: master 9 | 10 | project_type: app 11 | -------------------------------------------------------------------------------- /example/README.md: -------------------------------------------------------------------------------- 1 | # ktflutter_example 2 | 3 | Demonstrates how to use the ktflutter plugin. 4 | 5 | ## Getting Started 6 | 7 | This project is a starting point for a Flutter application. 8 | 9 | A few resources to get you started if this is your first Flutter project: 10 | 11 | - [Lab: Write your first Flutter app](https://flutter.dev/docs/get-started/codelab) 12 | - [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook) 13 | 14 | For help getting started with Flutter, view our 15 | [online documentation](https://flutter.dev/docs), which offers tutorials, 16 | samples, guidance on mobile development, and a full API reference. 17 | -------------------------------------------------------------------------------- /example/android/app/build.gradle: -------------------------------------------------------------------------------- 1 | def localProperties = new Properties() 2 | def localPropertiesFile = rootProject.file('local.properties') 3 | if (localPropertiesFile.exists()) { 4 | localPropertiesFile.withReader('UTF-8') { reader -> 5 | localProperties.load(reader) 6 | } 7 | } 8 | 9 | def flutterRoot = localProperties.getProperty('flutter.sdk') 10 | if (flutterRoot == null) { 11 | throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") 12 | } 13 | 14 | def flutterVersionCode = localProperties.getProperty('flutter.versionCode') 15 | if (flutterVersionCode == null) { 16 | flutterVersionCode = '1' 17 | } 18 | 19 | def flutterVersionName = localProperties.getProperty('flutter.versionName') 20 | if (flutterVersionName == null) { 21 | flutterVersionName = '1.0' 22 | } 23 | 24 | apply plugin: 'com.android.application' 25 | apply plugin: 'kotlin-android' 26 | apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" 27 | 28 | android { 29 | compileSdkVersion 28 30 | 31 | sourceSets { 32 | main.java.srcDirs += 'src/main/kotlin' 33 | } 34 | 35 | lintOptions { 36 | disable 'InvalidPackage' 37 | } 38 | 39 | defaultConfig { 40 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). 41 | applicationId "com.example.ktflutter_example" 42 | minSdkVersion 16 43 | targetSdkVersion 28 44 | versionCode flutterVersionCode.toInteger() 45 | versionName flutterVersionName 46 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 47 | } 48 | 49 | buildTypes { 50 | release { 51 | // TODO: Add your own signing config for the release build. 52 | // Signing with the debug keys for now, so `flutter run --release` works. 53 | signingConfig signingConfigs.debug 54 | } 55 | } 56 | } 57 | 58 | flutter { 59 | source '../..' 60 | } 61 | 62 | dependencies { 63 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" 64 | testImplementation 'junit:junit:4.12' 65 | androidTestImplementation 'com.android.support.test:runner:1.0.2' 66 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' 67 | } 68 | -------------------------------------------------------------------------------- /example/android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 9 | 13 | 20 | 24 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /example/android/app/src/main/kotlin/com/example/ktflutter_example/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.example.ktflutter_example 2 | 3 | import android.os.Bundle 4 | 5 | import io.flutter.app.FlutterActivity 6 | import io.flutter.plugins.GeneratedPluginRegistrant 7 | import com.rarnu.ktflutter.nativeRouting 8 | 9 | class MainActivity: FlutterActivity() { 10 | override fun onCreate(savedInstanceState: Bundle?) { 11 | super.onCreate(savedInstanceState) 12 | GeneratedPluginRegistrant.registerWith(this) 13 | 14 | nativeRouting { 15 | route("hello") { _, params -> 16 | "hello ${params["name"]}" 17 | } 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/drawable/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codemonarch/flutter_ktport/c9755624e5d51348be873bd1ad6561cab9453fae/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codemonarch/flutter_ktport/c9755624e5d51348be873bd1ad6561cab9453fae/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codemonarch/flutter_ktport/c9755624e5d51348be873bd1ad6561cab9453fae/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codemonarch/flutter_ktport/c9755624e5d51348be873bd1ad6561cab9453fae/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codemonarch/flutter_ktport/c9755624e5d51348be873bd1ad6561cab9453fae/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | -------------------------------------------------------------------------------- /example/android/app/src/profile/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/android/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext.kotlin_version = '1.2.71' 3 | repositories { 4 | google() 5 | jcenter() 6 | } 7 | 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:3.2.1' 10 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 11 | } 12 | } 13 | 14 | allprojects { 15 | repositories { 16 | google() 17 | jcenter() 18 | } 19 | } 20 | 21 | rootProject.buildDir = '../build' 22 | subprojects { 23 | project.buildDir = "${rootProject.buildDir}/${project.name}" 24 | } 25 | subprojects { 26 | project.evaluationDependsOn(':app') 27 | } 28 | 29 | task clean(type: Delete) { 30 | delete rootProject.buildDir 31 | } 32 | -------------------------------------------------------------------------------- /example/android/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx1536M 2 | 3 | -------------------------------------------------------------------------------- /example/android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Fri Jun 23 08:50:38 CEST 2017 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.4-all.zip 7 | -------------------------------------------------------------------------------- /example/android/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | 3 | def flutterProjectRoot = rootProject.projectDir.parentFile.toPath() 4 | 5 | def plugins = new Properties() 6 | def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins') 7 | if (pluginsFile.exists()) { 8 | pluginsFile.withReader('UTF-8') { reader -> plugins.load(reader) } 9 | } 10 | 11 | plugins.each { name, path -> 12 | def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile() 13 | include ":$name" 14 | project(":$name").projectDir = pluginDirectory 15 | } 16 | -------------------------------------------------------------------------------- /example/ios/Flutter/AppFrameworkInfo.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | App 9 | CFBundleIdentifier 10 | io.flutter.flutter.app 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | App 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1.0 23 | MinimumOSVersion 24 | 8.0 25 | 26 | 27 | -------------------------------------------------------------------------------- /example/ios/Flutter/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" 2 | #include "Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /example/ios/Flutter/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" 2 | #include "Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /example/ios/Podfile: -------------------------------------------------------------------------------- 1 | # Uncomment this line to define a global platform for your project 2 | # platform :ios, '9.0' 3 | 4 | # CocoaPods analytics sends network stats synchronously affecting flutter build latency. 5 | ENV['COCOAPODS_DISABLE_STATS'] = 'true' 6 | 7 | project 'Runner', { 8 | 'Debug' => :debug, 9 | 'Profile' => :release, 10 | 'Release' => :release, 11 | } 12 | 13 | def parse_KV_file(file, separator='=') 14 | file_abs_path = File.expand_path(file) 15 | if !File.exists? file_abs_path 16 | return []; 17 | end 18 | pods_ary = [] 19 | skip_line_start_symbols = ["#", "/"] 20 | File.foreach(file_abs_path) { |line| 21 | next if skip_line_start_symbols.any? { |symbol| line =~ /^\s*#{symbol}/ } 22 | plugin = line.split(pattern=separator) 23 | if plugin.length == 2 24 | podname = plugin[0].strip() 25 | path = plugin[1].strip() 26 | podpath = File.expand_path("#{path}", file_abs_path) 27 | pods_ary.push({:name => podname, :path => podpath}); 28 | else 29 | puts "Invalid plugin specification: #{line}" 30 | end 31 | } 32 | return pods_ary 33 | end 34 | 35 | target 'Runner' do 36 | use_frameworks! 37 | 38 | # Prepare symlinks folder. We use symlinks to avoid having Podfile.lock 39 | # referring to absolute paths on developers' machines. 40 | system('rm -rf .symlinks') 41 | system('mkdir -p .symlinks/plugins') 42 | 43 | # Flutter Pods 44 | generated_xcode_build_settings = parse_KV_file('./Flutter/Generated.xcconfig') 45 | if generated_xcode_build_settings.empty? 46 | puts "Generated.xcconfig must exist. If you're running pod install manually, make sure flutter pub get is executed first." 47 | end 48 | generated_xcode_build_settings.map { |p| 49 | if p[:name] == 'FLUTTER_FRAMEWORK_DIR' 50 | symlink = File.join('.symlinks', 'flutter') 51 | File.symlink(File.dirname(p[:path]), symlink) 52 | pod 'Flutter', :path => File.join(symlink, File.basename(p[:path])) 53 | end 54 | } 55 | 56 | # Plugin Pods 57 | plugin_pods = parse_KV_file('../.flutter-plugins') 58 | plugin_pods.map { |p| 59 | symlink = File.join('.symlinks', 'plugins', p[:name]) 60 | File.symlink(p[:path], symlink) 61 | pod p[:name], :path => File.join(symlink, 'ios') 62 | } 63 | end 64 | 65 | # Prevent Cocoapods from embedding a second Flutter framework and causing an error with the new Xcode build system. 66 | install! 'cocoapods', :disable_input_output_paths => true 67 | 68 | post_install do |installer| 69 | installer.pods_project.targets.each do |target| 70 | target.build_configurations.each do |config| 71 | config.build_settings['ENABLE_BITCODE'] = 'NO' 72 | end 73 | end 74 | end 75 | -------------------------------------------------------------------------------- /example/ios/Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - Flutter (1.0.0) 3 | - ktflutter (0.0.1): 4 | - Flutter 5 | 6 | DEPENDENCIES: 7 | - Flutter (from `.symlinks/flutter/ios`) 8 | - ktflutter (from `.symlinks/plugins/ktflutter/ios`) 9 | 10 | EXTERNAL SOURCES: 11 | Flutter: 12 | :path: ".symlinks/flutter/ios" 13 | ktflutter: 14 | :path: ".symlinks/plugins/ktflutter/ios" 15 | 16 | SPEC CHECKSUMS: 17 | Flutter: 58dd7d1b27887414a370fcccb9e645c08ffd7a6a 18 | ktflutter: 71ece579145b941bde09b0d6979ff2869b9b0ded 19 | 20 | PODFILE CHECKSUM: b6a0a141693093b304368d08511b46cf3d1d0ac5 21 | 22 | COCOAPODS: 1.7.2 23 | -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; 11 | 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; 12 | 3B80C3941E831B6300D905FE /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; }; 13 | 3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 14 | 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; }; 15 | 95694E0D21B1739553323E49 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2D5722D877A14353B72B600E /* Pods_Runner.framework */; }; 16 | 9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; }; 17 | 9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 18 | 9740EEB41CF90195004384FC /* Debug.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = 9740EEB21CF90195004384FC /* Debug.xcconfig */; }; 19 | 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; 20 | 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; 21 | 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; 22 | /* End PBXBuildFile section */ 23 | 24 | /* Begin PBXCopyFilesBuildPhase section */ 25 | 9705A1C41CF9048500538489 /* Embed Frameworks */ = { 26 | isa = PBXCopyFilesBuildPhase; 27 | buildActionMask = 2147483647; 28 | dstPath = ""; 29 | dstSubfolderSpec = 10; 30 | files = ( 31 | 3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */, 32 | 9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */, 33 | ); 34 | name = "Embed Frameworks"; 35 | runOnlyForDeploymentPostprocessing = 0; 36 | }; 37 | /* End PBXCopyFilesBuildPhase section */ 38 | 39 | /* Begin PBXFileReference section */ 40 | 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; 41 | 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; 42 | 2D5722D877A14353B72B600E /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 43 | 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; 44 | 3B80C3931E831B6300D905FE /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = Flutter/App.framework; sourceTree = ""; }; 45 | 5D51077BDF015956E639C44C /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = ""; }; 46 | 69C4D0E7B7F0E22E4A592404 /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = ""; }; 47 | 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = ""; }; 48 | 74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 49 | 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; 50 | 8468E314AAE59FE0ED8AA6DD /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = ""; }; 51 | 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = ""; }; 52 | 9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = ""; }; 53 | 9740EEBA1CF902C7004384FC /* Flutter.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Flutter.framework; path = Flutter/Flutter.framework; sourceTree = ""; }; 54 | 97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; }; 55 | 97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 56 | 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 57 | 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 58 | 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 59 | /* End PBXFileReference section */ 60 | 61 | /* Begin PBXFrameworksBuildPhase section */ 62 | 97C146EB1CF9000F007C117D /* Frameworks */ = { 63 | isa = PBXFrameworksBuildPhase; 64 | buildActionMask = 2147483647; 65 | files = ( 66 | 9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */, 67 | 3B80C3941E831B6300D905FE /* App.framework in Frameworks */, 68 | 95694E0D21B1739553323E49 /* Pods_Runner.framework in Frameworks */, 69 | ); 70 | runOnlyForDeploymentPostprocessing = 0; 71 | }; 72 | /* End PBXFrameworksBuildPhase section */ 73 | 74 | /* Begin PBXGroup section */ 75 | 64172EE5DD81DB9CC556ECBA /* Frameworks */ = { 76 | isa = PBXGroup; 77 | children = ( 78 | 2D5722D877A14353B72B600E /* Pods_Runner.framework */, 79 | ); 80 | name = Frameworks; 81 | sourceTree = ""; 82 | }; 83 | 9740EEB11CF90186004384FC /* Flutter */ = { 84 | isa = PBXGroup; 85 | children = ( 86 | 3B80C3931E831B6300D905FE /* App.framework */, 87 | 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */, 88 | 9740EEBA1CF902C7004384FC /* Flutter.framework */, 89 | 9740EEB21CF90195004384FC /* Debug.xcconfig */, 90 | 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, 91 | 9740EEB31CF90195004384FC /* Generated.xcconfig */, 92 | ); 93 | name = Flutter; 94 | sourceTree = ""; 95 | }; 96 | 97C146E51CF9000F007C117D = { 97 | isa = PBXGroup; 98 | children = ( 99 | 9740EEB11CF90186004384FC /* Flutter */, 100 | 97C146F01CF9000F007C117D /* Runner */, 101 | 97C146EF1CF9000F007C117D /* Products */, 102 | C06FC65AFA7903C75DDDEE09 /* Pods */, 103 | 64172EE5DD81DB9CC556ECBA /* Frameworks */, 104 | ); 105 | sourceTree = ""; 106 | }; 107 | 97C146EF1CF9000F007C117D /* Products */ = { 108 | isa = PBXGroup; 109 | children = ( 110 | 97C146EE1CF9000F007C117D /* Runner.app */, 111 | ); 112 | name = Products; 113 | sourceTree = ""; 114 | }; 115 | 97C146F01CF9000F007C117D /* Runner */ = { 116 | isa = PBXGroup; 117 | children = ( 118 | 97C146FA1CF9000F007C117D /* Main.storyboard */, 119 | 97C146FD1CF9000F007C117D /* Assets.xcassets */, 120 | 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */, 121 | 97C147021CF9000F007C117D /* Info.plist */, 122 | 97C146F11CF9000F007C117D /* Supporting Files */, 123 | 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */, 124 | 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */, 125 | 74858FAE1ED2DC5600515810 /* AppDelegate.swift */, 126 | 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */, 127 | ); 128 | path = Runner; 129 | sourceTree = ""; 130 | }; 131 | 97C146F11CF9000F007C117D /* Supporting Files */ = { 132 | isa = PBXGroup; 133 | children = ( 134 | ); 135 | name = "Supporting Files"; 136 | sourceTree = ""; 137 | }; 138 | C06FC65AFA7903C75DDDEE09 /* Pods */ = { 139 | isa = PBXGroup; 140 | children = ( 141 | 5D51077BDF015956E639C44C /* Pods-Runner.debug.xcconfig */, 142 | 8468E314AAE59FE0ED8AA6DD /* Pods-Runner.release.xcconfig */, 143 | 69C4D0E7B7F0E22E4A592404 /* Pods-Runner.profile.xcconfig */, 144 | ); 145 | path = Pods; 146 | sourceTree = ""; 147 | }; 148 | /* End PBXGroup section */ 149 | 150 | /* Begin PBXNativeTarget section */ 151 | 97C146ED1CF9000F007C117D /* Runner */ = { 152 | isa = PBXNativeTarget; 153 | buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */; 154 | buildPhases = ( 155 | C93C6646B7C9066AD9878C97 /* [CP] Check Pods Manifest.lock */, 156 | 9740EEB61CF901F6004384FC /* Run Script */, 157 | 97C146EA1CF9000F007C117D /* Sources */, 158 | 97C146EB1CF9000F007C117D /* Frameworks */, 159 | 97C146EC1CF9000F007C117D /* Resources */, 160 | 9705A1C41CF9048500538489 /* Embed Frameworks */, 161 | 3B06AD1E1E4923F5004D2608 /* Thin Binary */, 162 | F49C35C111A6F3EB9B3A5019 /* [CP] Embed Pods Frameworks */, 163 | ); 164 | buildRules = ( 165 | ); 166 | dependencies = ( 167 | ); 168 | name = Runner; 169 | productName = Runner; 170 | productReference = 97C146EE1CF9000F007C117D /* Runner.app */; 171 | productType = "com.apple.product-type.application"; 172 | }; 173 | /* End PBXNativeTarget section */ 174 | 175 | /* Begin PBXProject section */ 176 | 97C146E61CF9000F007C117D /* Project object */ = { 177 | isa = PBXProject; 178 | attributes = { 179 | LastUpgradeCheck = 1020; 180 | ORGANIZATIONNAME = "The Chromium Authors"; 181 | TargetAttributes = { 182 | 97C146ED1CF9000F007C117D = { 183 | CreatedOnToolsVersion = 7.3.1; 184 | LastSwiftMigration = 0910; 185 | }; 186 | }; 187 | }; 188 | buildConfigurationList = 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */; 189 | compatibilityVersion = "Xcode 3.2"; 190 | developmentRegion = en; 191 | hasScannedForEncodings = 0; 192 | knownRegions = ( 193 | en, 194 | Base, 195 | ); 196 | mainGroup = 97C146E51CF9000F007C117D; 197 | productRefGroup = 97C146EF1CF9000F007C117D /* Products */; 198 | projectDirPath = ""; 199 | projectRoot = ""; 200 | targets = ( 201 | 97C146ED1CF9000F007C117D /* Runner */, 202 | ); 203 | }; 204 | /* End PBXProject section */ 205 | 206 | /* Begin PBXResourcesBuildPhase section */ 207 | 97C146EC1CF9000F007C117D /* Resources */ = { 208 | isa = PBXResourcesBuildPhase; 209 | buildActionMask = 2147483647; 210 | files = ( 211 | 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */, 212 | 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */, 213 | 9740EEB41CF90195004384FC /* Debug.xcconfig in Resources */, 214 | 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */, 215 | 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */, 216 | ); 217 | runOnlyForDeploymentPostprocessing = 0; 218 | }; 219 | /* End PBXResourcesBuildPhase section */ 220 | 221 | /* Begin PBXShellScriptBuildPhase section */ 222 | 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { 223 | isa = PBXShellScriptBuildPhase; 224 | buildActionMask = 2147483647; 225 | files = ( 226 | ); 227 | inputPaths = ( 228 | ); 229 | name = "Thin Binary"; 230 | outputPaths = ( 231 | ); 232 | runOnlyForDeploymentPostprocessing = 0; 233 | shellPath = /bin/sh; 234 | shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" thin"; 235 | }; 236 | 9740EEB61CF901F6004384FC /* Run Script */ = { 237 | isa = PBXShellScriptBuildPhase; 238 | buildActionMask = 2147483647; 239 | files = ( 240 | ); 241 | inputPaths = ( 242 | ); 243 | name = "Run Script"; 244 | outputPaths = ( 245 | ); 246 | runOnlyForDeploymentPostprocessing = 0; 247 | shellPath = /bin/sh; 248 | shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build"; 249 | }; 250 | C93C6646B7C9066AD9878C97 /* [CP] Check Pods Manifest.lock */ = { 251 | isa = PBXShellScriptBuildPhase; 252 | buildActionMask = 2147483647; 253 | files = ( 254 | ); 255 | inputFileListPaths = ( 256 | ); 257 | inputPaths = ( 258 | "${PODS_PODFILE_DIR_PATH}/Podfile.lock", 259 | "${PODS_ROOT}/Manifest.lock", 260 | ); 261 | name = "[CP] Check Pods Manifest.lock"; 262 | outputFileListPaths = ( 263 | ); 264 | outputPaths = ( 265 | "$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt", 266 | ); 267 | runOnlyForDeploymentPostprocessing = 0; 268 | shellPath = /bin/sh; 269 | shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; 270 | showEnvVarsInLog = 0; 271 | }; 272 | F49C35C111A6F3EB9B3A5019 /* [CP] Embed Pods Frameworks */ = { 273 | isa = PBXShellScriptBuildPhase; 274 | buildActionMask = 2147483647; 275 | files = ( 276 | ); 277 | inputPaths = ( 278 | ); 279 | name = "[CP] Embed Pods Frameworks"; 280 | outputPaths = ( 281 | ); 282 | runOnlyForDeploymentPostprocessing = 0; 283 | shellPath = /bin/sh; 284 | shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n"; 285 | showEnvVarsInLog = 0; 286 | }; 287 | /* End PBXShellScriptBuildPhase section */ 288 | 289 | /* Begin PBXSourcesBuildPhase section */ 290 | 97C146EA1CF9000F007C117D /* Sources */ = { 291 | isa = PBXSourcesBuildPhase; 292 | buildActionMask = 2147483647; 293 | files = ( 294 | 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */, 295 | 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */, 296 | ); 297 | runOnlyForDeploymentPostprocessing = 0; 298 | }; 299 | /* End PBXSourcesBuildPhase section */ 300 | 301 | /* Begin PBXVariantGroup section */ 302 | 97C146FA1CF9000F007C117D /* Main.storyboard */ = { 303 | isa = PBXVariantGroup; 304 | children = ( 305 | 97C146FB1CF9000F007C117D /* Base */, 306 | ); 307 | name = Main.storyboard; 308 | sourceTree = ""; 309 | }; 310 | 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */ = { 311 | isa = PBXVariantGroup; 312 | children = ( 313 | 97C147001CF9000F007C117D /* Base */, 314 | ); 315 | name = LaunchScreen.storyboard; 316 | sourceTree = ""; 317 | }; 318 | /* End PBXVariantGroup section */ 319 | 320 | /* Begin XCBuildConfiguration section */ 321 | 249021D3217E4FDB00AE95B9 /* Profile */ = { 322 | isa = XCBuildConfiguration; 323 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; 324 | buildSettings = { 325 | ALWAYS_SEARCH_USER_PATHS = NO; 326 | CLANG_ANALYZER_NONNULL = YES; 327 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 328 | CLANG_CXX_LIBRARY = "libc++"; 329 | CLANG_ENABLE_MODULES = YES; 330 | CLANG_ENABLE_OBJC_ARC = YES; 331 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 332 | CLANG_WARN_BOOL_CONVERSION = YES; 333 | CLANG_WARN_COMMA = YES; 334 | CLANG_WARN_CONSTANT_CONVERSION = YES; 335 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 336 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 337 | CLANG_WARN_EMPTY_BODY = YES; 338 | CLANG_WARN_ENUM_CONVERSION = YES; 339 | CLANG_WARN_INFINITE_RECURSION = YES; 340 | CLANG_WARN_INT_CONVERSION = YES; 341 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 342 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 343 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 344 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 345 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 346 | CLANG_WARN_STRICT_PROTOTYPES = YES; 347 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 348 | CLANG_WARN_UNREACHABLE_CODE = YES; 349 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 350 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 351 | COPY_PHASE_STRIP = NO; 352 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 353 | ENABLE_NS_ASSERTIONS = NO; 354 | ENABLE_STRICT_OBJC_MSGSEND = YES; 355 | GCC_C_LANGUAGE_STANDARD = gnu99; 356 | GCC_NO_COMMON_BLOCKS = YES; 357 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 358 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 359 | GCC_WARN_UNDECLARED_SELECTOR = YES; 360 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 361 | GCC_WARN_UNUSED_FUNCTION = YES; 362 | GCC_WARN_UNUSED_VARIABLE = YES; 363 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 364 | MTL_ENABLE_DEBUG_INFO = NO; 365 | SDKROOT = iphoneos; 366 | TARGETED_DEVICE_FAMILY = "1,2"; 367 | VALIDATE_PRODUCT = YES; 368 | }; 369 | name = Profile; 370 | }; 371 | 249021D4217E4FDB00AE95B9 /* Profile */ = { 372 | isa = XCBuildConfiguration; 373 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; 374 | buildSettings = { 375 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 376 | CURRENT_PROJECT_VERSION = 1.0; 377 | DEVELOPMENT_TEAM = S8QB4VV633; 378 | ENABLE_BITCODE = NO; 379 | FRAMEWORK_SEARCH_PATHS = ( 380 | "$(inherited)", 381 | "$(PROJECT_DIR)/Flutter", 382 | ); 383 | INFOPLIST_FILE = Runner/Info.plist; 384 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 385 | LIBRARY_SEARCH_PATHS = ( 386 | "$(inherited)", 387 | "$(PROJECT_DIR)/Flutter", 388 | ); 389 | MARKETING_VERSION = 1; 390 | PRODUCT_BUNDLE_IDENTIFIER = com.example.ktflutterExample; 391 | PRODUCT_NAME = "$(TARGET_NAME)"; 392 | SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; 393 | SWIFT_VERSION = 4.0; 394 | VERSIONING_SYSTEM = "apple-generic"; 395 | }; 396 | name = Profile; 397 | }; 398 | 97C147031CF9000F007C117D /* Debug */ = { 399 | isa = XCBuildConfiguration; 400 | baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; 401 | buildSettings = { 402 | ALWAYS_SEARCH_USER_PATHS = NO; 403 | CLANG_ANALYZER_NONNULL = YES; 404 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 405 | CLANG_CXX_LIBRARY = "libc++"; 406 | CLANG_ENABLE_MODULES = YES; 407 | CLANG_ENABLE_OBJC_ARC = YES; 408 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 409 | CLANG_WARN_BOOL_CONVERSION = YES; 410 | CLANG_WARN_COMMA = YES; 411 | CLANG_WARN_CONSTANT_CONVERSION = YES; 412 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 413 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 414 | CLANG_WARN_EMPTY_BODY = YES; 415 | CLANG_WARN_ENUM_CONVERSION = YES; 416 | CLANG_WARN_INFINITE_RECURSION = YES; 417 | CLANG_WARN_INT_CONVERSION = YES; 418 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 419 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 420 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 421 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 422 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 423 | CLANG_WARN_STRICT_PROTOTYPES = YES; 424 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 425 | CLANG_WARN_UNREACHABLE_CODE = YES; 426 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 427 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 428 | COPY_PHASE_STRIP = NO; 429 | DEBUG_INFORMATION_FORMAT = dwarf; 430 | ENABLE_STRICT_OBJC_MSGSEND = YES; 431 | ENABLE_TESTABILITY = YES; 432 | GCC_C_LANGUAGE_STANDARD = gnu99; 433 | GCC_DYNAMIC_NO_PIC = NO; 434 | GCC_NO_COMMON_BLOCKS = YES; 435 | GCC_OPTIMIZATION_LEVEL = 0; 436 | GCC_PREPROCESSOR_DEFINITIONS = ( 437 | "DEBUG=1", 438 | "$(inherited)", 439 | ); 440 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 441 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 442 | GCC_WARN_UNDECLARED_SELECTOR = YES; 443 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 444 | GCC_WARN_UNUSED_FUNCTION = YES; 445 | GCC_WARN_UNUSED_VARIABLE = YES; 446 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 447 | MTL_ENABLE_DEBUG_INFO = YES; 448 | ONLY_ACTIVE_ARCH = YES; 449 | SDKROOT = iphoneos; 450 | TARGETED_DEVICE_FAMILY = "1,2"; 451 | }; 452 | name = Debug; 453 | }; 454 | 97C147041CF9000F007C117D /* Release */ = { 455 | isa = XCBuildConfiguration; 456 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; 457 | buildSettings = { 458 | ALWAYS_SEARCH_USER_PATHS = NO; 459 | CLANG_ANALYZER_NONNULL = YES; 460 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 461 | CLANG_CXX_LIBRARY = "libc++"; 462 | CLANG_ENABLE_MODULES = YES; 463 | CLANG_ENABLE_OBJC_ARC = YES; 464 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 465 | CLANG_WARN_BOOL_CONVERSION = YES; 466 | CLANG_WARN_COMMA = YES; 467 | CLANG_WARN_CONSTANT_CONVERSION = YES; 468 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 469 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 470 | CLANG_WARN_EMPTY_BODY = YES; 471 | CLANG_WARN_ENUM_CONVERSION = YES; 472 | CLANG_WARN_INFINITE_RECURSION = YES; 473 | CLANG_WARN_INT_CONVERSION = YES; 474 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 475 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 476 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 477 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 478 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 479 | CLANG_WARN_STRICT_PROTOTYPES = YES; 480 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 481 | CLANG_WARN_UNREACHABLE_CODE = YES; 482 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 483 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 484 | COPY_PHASE_STRIP = NO; 485 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 486 | ENABLE_NS_ASSERTIONS = NO; 487 | ENABLE_STRICT_OBJC_MSGSEND = YES; 488 | GCC_C_LANGUAGE_STANDARD = gnu99; 489 | GCC_NO_COMMON_BLOCKS = YES; 490 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 491 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 492 | GCC_WARN_UNDECLARED_SELECTOR = YES; 493 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 494 | GCC_WARN_UNUSED_FUNCTION = YES; 495 | GCC_WARN_UNUSED_VARIABLE = YES; 496 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 497 | MTL_ENABLE_DEBUG_INFO = NO; 498 | SDKROOT = iphoneos; 499 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 500 | TARGETED_DEVICE_FAMILY = "1,2"; 501 | VALIDATE_PRODUCT = YES; 502 | }; 503 | name = Release; 504 | }; 505 | 97C147061CF9000F007C117D /* Debug */ = { 506 | isa = XCBuildConfiguration; 507 | baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; 508 | buildSettings = { 509 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 510 | CLANG_ENABLE_MODULES = YES; 511 | CURRENT_PROJECT_VERSION = 1.0; 512 | ENABLE_BITCODE = NO; 513 | FRAMEWORK_SEARCH_PATHS = ( 514 | "$(inherited)", 515 | "$(PROJECT_DIR)/Flutter", 516 | ); 517 | INFOPLIST_FILE = Runner/Info.plist; 518 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 519 | LIBRARY_SEARCH_PATHS = ( 520 | "$(inherited)", 521 | "$(PROJECT_DIR)/Flutter", 522 | ); 523 | MARKETING_VERSION = 1; 524 | PRODUCT_BUNDLE_IDENTIFIER = com.example.ktflutterExample; 525 | PRODUCT_NAME = "$(TARGET_NAME)"; 526 | SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; 527 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 528 | SWIFT_SWIFT3_OBJC_INFERENCE = On; 529 | SWIFT_VERSION = 4.0; 530 | VERSIONING_SYSTEM = "apple-generic"; 531 | }; 532 | name = Debug; 533 | }; 534 | 97C147071CF9000F007C117D /* Release */ = { 535 | isa = XCBuildConfiguration; 536 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; 537 | buildSettings = { 538 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 539 | CLANG_ENABLE_MODULES = YES; 540 | CURRENT_PROJECT_VERSION = 1.0; 541 | ENABLE_BITCODE = NO; 542 | FRAMEWORK_SEARCH_PATHS = ( 543 | "$(inherited)", 544 | "$(PROJECT_DIR)/Flutter", 545 | ); 546 | INFOPLIST_FILE = Runner/Info.plist; 547 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 548 | LIBRARY_SEARCH_PATHS = ( 549 | "$(inherited)", 550 | "$(PROJECT_DIR)/Flutter", 551 | ); 552 | MARKETING_VERSION = 1; 553 | PRODUCT_BUNDLE_IDENTIFIER = com.example.ktflutterExample; 554 | PRODUCT_NAME = "$(TARGET_NAME)"; 555 | SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; 556 | SWIFT_SWIFT3_OBJC_INFERENCE = On; 557 | SWIFT_VERSION = 4.0; 558 | VERSIONING_SYSTEM = "apple-generic"; 559 | }; 560 | name = Release; 561 | }; 562 | /* End XCBuildConfiguration section */ 563 | 564 | /* Begin XCConfigurationList section */ 565 | 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */ = { 566 | isa = XCConfigurationList; 567 | buildConfigurations = ( 568 | 97C147031CF9000F007C117D /* Debug */, 569 | 97C147041CF9000F007C117D /* Release */, 570 | 249021D3217E4FDB00AE95B9 /* Profile */, 571 | ); 572 | defaultConfigurationIsVisible = 0; 573 | defaultConfigurationName = Release; 574 | }; 575 | 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */ = { 576 | isa = XCConfigurationList; 577 | buildConfigurations = ( 578 | 97C147061CF9000F007C117D /* Debug */, 579 | 97C147071CF9000F007C117D /* Release */, 580 | 249021D4217E4FDB00AE95B9 /* Profile */, 581 | ); 582 | defaultConfigurationIsVisible = 0; 583 | defaultConfigurationName = Release; 584 | }; 585 | /* End XCConfigurationList section */ 586 | }; 587 | rootObject = 97C146E61CF9000F007C117D /* Project object */; 588 | } 589 | -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 56 | 62 | 63 | 64 | 65 | 66 | 67 | 73 | 75 | 81 | 82 | 83 | 84 | 86 | 87 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /example/ios/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/ios/Runner/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | import Flutter 3 | import ktflutter 4 | 5 | @UIApplicationMain 6 | @objc class AppDelegate: FlutterAppDelegate { 7 | override func application( 8 | _ application: UIApplication, 9 | didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]? 10 | ) -> Bool { 11 | GeneratedPluginRegistrant.register(with: self) 12 | 13 | nativeRouting { 14 | $0.route("hello") { params in 15 | return "hello \(params["name"] as! String)" 16 | } 17 | } 18 | 19 | return super.application(application, didFinishLaunchingWithOptions: launchOptions) 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "20x20", 5 | "idiom" : "iphone", 6 | "filename" : "Icon-App-20x20@2x.png", 7 | "scale" : "2x" 8 | }, 9 | { 10 | "size" : "20x20", 11 | "idiom" : "iphone", 12 | "filename" : "Icon-App-20x20@3x.png", 13 | "scale" : "3x" 14 | }, 15 | { 16 | "size" : "29x29", 17 | "idiom" : "iphone", 18 | "filename" : "Icon-App-29x29@1x.png", 19 | "scale" : "1x" 20 | }, 21 | { 22 | "size" : "29x29", 23 | "idiom" : "iphone", 24 | "filename" : "Icon-App-29x29@2x.png", 25 | "scale" : "2x" 26 | }, 27 | { 28 | "size" : "29x29", 29 | "idiom" : "iphone", 30 | "filename" : "Icon-App-29x29@3x.png", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "size" : "40x40", 35 | "idiom" : "iphone", 36 | "filename" : "Icon-App-40x40@2x.png", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "size" : "40x40", 41 | "idiom" : "iphone", 42 | "filename" : "Icon-App-40x40@3x.png", 43 | "scale" : "3x" 44 | }, 45 | { 46 | "size" : "60x60", 47 | "idiom" : "iphone", 48 | "filename" : "Icon-App-60x60@2x.png", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "size" : "60x60", 53 | "idiom" : "iphone", 54 | "filename" : "Icon-App-60x60@3x.png", 55 | "scale" : "3x" 56 | }, 57 | { 58 | "size" : "20x20", 59 | "idiom" : "ipad", 60 | "filename" : "Icon-App-20x20@1x.png", 61 | "scale" : "1x" 62 | }, 63 | { 64 | "size" : "20x20", 65 | "idiom" : "ipad", 66 | "filename" : "Icon-App-20x20@2x.png", 67 | "scale" : "2x" 68 | }, 69 | { 70 | "size" : "29x29", 71 | "idiom" : "ipad", 72 | "filename" : "Icon-App-29x29@1x.png", 73 | "scale" : "1x" 74 | }, 75 | { 76 | "size" : "29x29", 77 | "idiom" : "ipad", 78 | "filename" : "Icon-App-29x29@2x.png", 79 | "scale" : "2x" 80 | }, 81 | { 82 | "size" : "40x40", 83 | "idiom" : "ipad", 84 | "filename" : "Icon-App-40x40@1x.png", 85 | "scale" : "1x" 86 | }, 87 | { 88 | "size" : "40x40", 89 | "idiom" : "ipad", 90 | "filename" : "Icon-App-40x40@2x.png", 91 | "scale" : "2x" 92 | }, 93 | { 94 | "size" : "76x76", 95 | "idiom" : "ipad", 96 | "filename" : "Icon-App-76x76@1x.png", 97 | "scale" : "1x" 98 | }, 99 | { 100 | "size" : "76x76", 101 | "idiom" : "ipad", 102 | "filename" : "Icon-App-76x76@2x.png", 103 | "scale" : "2x" 104 | }, 105 | { 106 | "size" : "83.5x83.5", 107 | "idiom" : "ipad", 108 | "filename" : "Icon-App-83.5x83.5@2x.png", 109 | "scale" : "2x" 110 | }, 111 | { 112 | "size" : "1024x1024", 113 | "idiom" : "ios-marketing", 114 | "filename" : "Icon-App-1024x1024@1x.png", 115 | "scale" : "1x" 116 | } 117 | ], 118 | "info" : { 119 | "version" : 1, 120 | "author" : "xcode" 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codemonarch/flutter_ktport/c9755624e5d51348be873bd1ad6561cab9453fae/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codemonarch/flutter_ktport/c9755624e5d51348be873bd1ad6561cab9453fae/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codemonarch/flutter_ktport/c9755624e5d51348be873bd1ad6561cab9453fae/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codemonarch/flutter_ktport/c9755624e5d51348be873bd1ad6561cab9453fae/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codemonarch/flutter_ktport/c9755624e5d51348be873bd1ad6561cab9453fae/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codemonarch/flutter_ktport/c9755624e5d51348be873bd1ad6561cab9453fae/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codemonarch/flutter_ktport/c9755624e5d51348be873bd1ad6561cab9453fae/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codemonarch/flutter_ktport/c9755624e5d51348be873bd1ad6561cab9453fae/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codemonarch/flutter_ktport/c9755624e5d51348be873bd1ad6561cab9453fae/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codemonarch/flutter_ktport/c9755624e5d51348be873bd1ad6561cab9453fae/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codemonarch/flutter_ktport/c9755624e5d51348be873bd1ad6561cab9453fae/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codemonarch/flutter_ktport/c9755624e5d51348be873bd1ad6561cab9453fae/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codemonarch/flutter_ktport/c9755624e5d51348be873bd1ad6561cab9453fae/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codemonarch/flutter_ktport/c9755624e5d51348be873bd1ad6561cab9453fae/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codemonarch/flutter_ktport/c9755624e5d51348be873bd1ad6561cab9453fae/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "LaunchImage.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "LaunchImage@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "LaunchImage@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codemonarch/flutter_ktport/c9755624e5d51348be873bd1ad6561cab9453fae/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codemonarch/flutter_ktport/c9755624e5d51348be873bd1ad6561cab9453fae/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codemonarch/flutter_ktport/c9755624e5d51348be873bd1ad6561cab9453fae/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md: -------------------------------------------------------------------------------- 1 | # Launch Screen Assets 2 | 3 | You can customize the launch screen with your own desired assets by replacing the image files in this directory. 4 | 5 | You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images. -------------------------------------------------------------------------------- /example/ios/Runner/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /example/ios/Runner/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /example/ios/Runner/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ktflutter_example 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | $(MARKETING_VERSION) 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | $(CURRENT_PROJECT_VERSION) 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UISupportedInterfaceOrientations 30 | 31 | UIInterfaceOrientationPortrait 32 | UIInterfaceOrientationLandscapeLeft 33 | UIInterfaceOrientationLandscapeRight 34 | 35 | UISupportedInterfaceOrientations~ipad 36 | 37 | UIInterfaceOrientationPortrait 38 | UIInterfaceOrientationPortraitUpsideDown 39 | UIInterfaceOrientationLandscapeLeft 40 | UIInterfaceOrientationLandscapeRight 41 | 42 | UIViewControllerBasedStatusBarAppearance 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /example/ios/Runner/Runner-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | #import "GeneratedPluginRegistrant.h" -------------------------------------------------------------------------------- /example/lib/main.dart: -------------------------------------------------------------------------------- 1 | import 'dart:io'; 2 | 3 | import 'package:flutter/material.dart'; 4 | import 'package:flutter/services.dart'; 5 | import 'package:ktflutter/download_extension.dart'; 6 | import 'package:ktflutter/global_extension.dart'; 7 | import 'package:ktflutter/route_extension.dart'; 8 | import 'package:ktflutter/string_extension.dart'; 9 | import 'package:ktflutter/toast_extension.dart'; 10 | 11 | void main() => runApp(MainApp()); 12 | 13 | class MainApp extends StatelessWidget { 14 | Widget build(BuildContext context) => MaterialApp( 15 | theme: ThemeData( 16 | brightness: Brightness.dark, 17 | primarySwatch: Colors.blue, 18 | ), 19 | home: HomePage(), 20 | ); 21 | } 22 | 23 | class HomePage extends StatefulWidget { 24 | _HomePageState createState() => _HomePageState(); 25 | } 26 | 27 | class SizedButon extends SizedBox { 28 | SizedButon({ 29 | Key key, 30 | double width = 300.0, 31 | double height = 42.0, 32 | String title = "", 33 | @required VoidCallback onPressed 34 | }) : super( 35 | key: key, 36 | width: width, 37 | height: height, 38 | child: Container( 39 | margin: EdgeInsets.only(bottom: 8.0), 40 | child: RaisedButton( 41 | child: Text(title), 42 | onPressed: onPressed, 43 | ), 44 | ) 45 | ); 46 | } 47 | 48 | class SizedProgress extends SizedBox { 49 | SizedProgress({ 50 | Key key, 51 | double width = 300.0, 52 | double height = 16.0, 53 | double value = 0.0 54 | }): super( 55 | key: key, 56 | width: width, 57 | height: height, 58 | child: Container( 59 | margin: EdgeInsets.only(bottom: 8.0), 60 | child: LinearProgressIndicator( 61 | value: value, 62 | ), 63 | ) 64 | ); 65 | } 66 | 67 | class _HomePageState extends State { 68 | 69 | File _imgFile; 70 | bool _isDownloading = false; 71 | double _progress = 0; 72 | 73 | _HomePageState(): super() { 74 | deviceFilePath((path) { 75 | _imgFile = File("$path/sample.jpg"); 76 | print("imgFile => ${_imgFile.path}"); 77 | }); 78 | } 79 | 80 | List _makeWidgets() { 81 | var ret = [ 82 | Container( 83 | margin: EdgeInsets.fromLTRB(0, 16.0, 0, 8.0), 84 | child: Text('Running on: 23333\n'), 85 | ), 86 | SizedButon( 87 | title: "Device Method Test", 88 | onPressed: _testDeviceMethods, 89 | ), 90 | SizedButon( 91 | title: "Download Test", 92 | onPressed: _testDownload, 93 | ), 94 | SizedButon( 95 | title: "Delete Download File", 96 | onPressed: _testDeleteDownloadFile), 97 | SizedButon( 98 | title: 'Toast Test', 99 | onPressed: _testToast, 100 | ), 101 | SizedButon( 102 | title: 'String Test', 103 | onPressed: _testString, 104 | ), 105 | SizedButon( 106 | title: 'Route Test', 107 | onPressed: _testRoute, 108 | ), 109 | ]; 110 | if (_isDownloading) { 111 | ret.add(SizedProgress( 112 | value: _progress, 113 | )); 114 | } 115 | if (_imgFile != null && _imgFile.existsSync()) { 116 | ret.add(Image.file(_imgFile, width: 300, height: 200, fit: BoxFit.fill,)); 117 | } 118 | return ret; 119 | } 120 | 121 | _testDeviceMethods() { 122 | platform((it) => print("platform => $it")); 123 | appVersionCode((it) => print("appVersionCode => $it")); 124 | appVersionName((it) => print("appVersionName => $it")); 125 | deviceVersion((it) => print("deviceVersion => $it")); 126 | deviceModel((it) => print("deviceModel => $it")); 127 | deviceId((it) => print("deviceId => $it")); 128 | appBundle((b) => print("bundle => $b")); 129 | appPackage((p) => print("package => $p")); 130 | // paths 131 | deviceDocumentPath((path) => print("document => $path")); 132 | deviceFilePath((path) => print("file => $path")); 133 | deviceCachePath((path) => print("cache => $path")); 134 | // android only 135 | deviceExternalPath((path) => print("sdcard => $path")); 136 | deviceExternalDocumentPath((path) => print("sdcard_document => $path")); 137 | deviceExternalFilePath((path) => print("sdcard_file=> $path")); 138 | deviceExternalCachePath((path) => print("sdcard_cache=> $path")); 139 | deviceObbPath((path) => print("obb=> $path")); 140 | } 141 | _testDownload() { 142 | var imageurl = "https://n1image.hjfile.cn/zhuanti/2019/07/08/bb6fa594eaa236b1a567a68cc0c3e1b0.jpg"; 143 | // var imageurl = 'https://n1image.hjfile.cn/hjclass/public/upload/201712/8697783b-253e-4e2a-aecb-bd1561c35667.jpg'; 144 | deviceFilePath((path) { 145 | _imgFile = File("$path/sample.jpg"); 146 | download(imageurl, _imgFile.path, (state, position, filesize, error) => setState(() { 147 | switch(state) { 148 | case DownloadState.Start: 149 | _isDownloading = true; 150 | _progress = 0; 151 | break; 152 | case DownloadState.Progress: 153 | _progress = (position / filesize); 154 | break; 155 | case DownloadState.Complete: 156 | _isDownloading = false; 157 | break; 158 | case DownloadState.Error: 159 | _isDownloading = false; 160 | break; 161 | } 162 | })); 163 | }); 164 | } 165 | 166 | _testDeleteDownloadFile() { 167 | if (_imgFile.existsSync()) { 168 | _imgFile.deleteSync(); 169 | setState(() {}); 170 | } 171 | } 172 | 173 | _testToast() { 174 | toast(context, "6666"); 175 | } 176 | _testString() { 177 | var str = stringOf("abcdefg"); 178 | var enc = str.base64encode(); 179 | var dec = enc.base64decode(); 180 | print("encoded => $enc"); 181 | print("decoded => $dec"); 182 | } 183 | _testRoute() { 184 | route("hello", { 'name': 'rarnu'}, (it) => print(it)); 185 | } 186 | 187 | Widget build(BuildContext context) => Scaffold( 188 | appBar: AppBar( 189 | title: Text('Plugin example app'), 190 | ), 191 | body: Center( 192 | child: Column( 193 | children: _makeWidgets() 194 | ), 195 | ), 196 | ); 197 | } 198 | -------------------------------------------------------------------------------- /example/pubspec.lock: -------------------------------------------------------------------------------- 1 | # Generated by pub 2 | # See https://dart.dev/tools/pub/glossary#lockfile 3 | packages: 4 | async: 5 | dependency: transitive 6 | description: 7 | name: async 8 | url: "https://pub.dartlang.org" 9 | source: hosted 10 | version: "2.2.0" 11 | boolean_selector: 12 | dependency: transitive 13 | description: 14 | name: boolean_selector 15 | url: "https://pub.dartlang.org" 16 | source: hosted 17 | version: "1.0.5" 18 | charcode: 19 | dependency: transitive 20 | description: 21 | name: charcode 22 | url: "https://pub.dartlang.org" 23 | source: hosted 24 | version: "1.1.2" 25 | collection: 26 | dependency: transitive 27 | description: 28 | name: collection 29 | url: "https://pub.dartlang.org" 30 | source: hosted 31 | version: "1.14.11" 32 | cupertino_icons: 33 | dependency: "direct main" 34 | description: 35 | name: cupertino_icons 36 | url: "https://pub.dartlang.org" 37 | source: hosted 38 | version: "0.1.2" 39 | flutter: 40 | dependency: "direct main" 41 | description: flutter 42 | source: sdk 43 | version: "0.0.0" 44 | flutter_test: 45 | dependency: "direct dev" 46 | description: flutter 47 | source: sdk 48 | version: "0.0.0" 49 | ktflutter: 50 | dependency: "direct dev" 51 | description: 52 | path: ".." 53 | relative: true 54 | source: path 55 | version: "1.0.1" 56 | matcher: 57 | dependency: transitive 58 | description: 59 | name: matcher 60 | url: "https://pub.dartlang.org" 61 | source: hosted 62 | version: "0.12.5" 63 | meta: 64 | dependency: transitive 65 | description: 66 | name: meta 67 | url: "https://pub.dartlang.org" 68 | source: hosted 69 | version: "1.1.6" 70 | path: 71 | dependency: transitive 72 | description: 73 | name: path 74 | url: "https://pub.dartlang.org" 75 | source: hosted 76 | version: "1.6.2" 77 | pedantic: 78 | dependency: transitive 79 | description: 80 | name: pedantic 81 | url: "https://pub.dartlang.org" 82 | source: hosted 83 | version: "1.7.0" 84 | quiver: 85 | dependency: transitive 86 | description: 87 | name: quiver 88 | url: "https://pub.dartlang.org" 89 | source: hosted 90 | version: "2.0.3" 91 | sky_engine: 92 | dependency: transitive 93 | description: flutter 94 | source: sdk 95 | version: "0.0.99" 96 | source_span: 97 | dependency: transitive 98 | description: 99 | name: source_span 100 | url: "https://pub.dartlang.org" 101 | source: hosted 102 | version: "1.5.5" 103 | stack_trace: 104 | dependency: transitive 105 | description: 106 | name: stack_trace 107 | url: "https://pub.dartlang.org" 108 | source: hosted 109 | version: "1.9.3" 110 | stream_channel: 111 | dependency: transitive 112 | description: 113 | name: stream_channel 114 | url: "https://pub.dartlang.org" 115 | source: hosted 116 | version: "2.0.0" 117 | string_scanner: 118 | dependency: transitive 119 | description: 120 | name: string_scanner 121 | url: "https://pub.dartlang.org" 122 | source: hosted 123 | version: "1.0.4" 124 | term_glyph: 125 | dependency: transitive 126 | description: 127 | name: term_glyph 128 | url: "https://pub.dartlang.org" 129 | source: hosted 130 | version: "1.1.0" 131 | test_api: 132 | dependency: transitive 133 | description: 134 | name: test_api 135 | url: "https://pub.dartlang.org" 136 | source: hosted 137 | version: "0.2.5" 138 | typed_data: 139 | dependency: transitive 140 | description: 141 | name: typed_data 142 | url: "https://pub.dartlang.org" 143 | source: hosted 144 | version: "1.1.6" 145 | vector_math: 146 | dependency: transitive 147 | description: 148 | name: vector_math 149 | url: "https://pub.dartlang.org" 150 | source: hosted 151 | version: "2.0.8" 152 | sdks: 153 | dart: ">=2.2.2 <3.0.0" 154 | -------------------------------------------------------------------------------- /example/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: ktflutter_example 2 | description: Demonstrates how to use the ktflutter plugin. 3 | publish_to: 'none' 4 | 5 | environment: 6 | sdk: ">=2.1.0 <3.0.0" 7 | 8 | dependencies: 9 | flutter: 10 | sdk: flutter 11 | 12 | cupertino_icons: ^0.1.2 13 | 14 | dev_dependencies: 15 | flutter_test: 16 | sdk: flutter 17 | 18 | ktflutter: 19 | path: ../ 20 | 21 | flutter: 22 | 23 | uses-material-design: true 24 | -------------------------------------------------------------------------------- /example/test/widget_test.dart: -------------------------------------------------------------------------------- 1 | // This is a basic Flutter widget test. 2 | // 3 | // To perform an interaction with a widget in your test, use the WidgetTester 4 | // utility that Flutter provides. For example, you can send tap and scroll 5 | // gestures. You can also use WidgetTester to find child widgets in the widget 6 | // tree, read text, and verify that the values of widget properties are correct. 7 | 8 | import 'package:flutter/material.dart'; 9 | import 'package:flutter_test/flutter_test.dart'; 10 | 11 | import 'package:ktflutter_example/main.dart'; 12 | 13 | void main() { 14 | testWidgets('Verify Platform version', (WidgetTester tester) async { 15 | // Build our app and trigger a frame. 16 | await tester.pumpWidget(MainApp()); 17 | 18 | // Verify that platform version is retrieved. 19 | expect( 20 | find.byWidgetPredicate( 21 | (Widget widget) => widget is Text && 22 | widget.data.startsWith('Running on:'), 23 | ), 24 | findsOneWidget, 25 | ); 26 | }); 27 | } 28 | -------------------------------------------------------------------------------- /ios/.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | .vagrant/ 3 | .sconsign.dblite 4 | .svn/ 5 | 6 | .DS_Store 7 | *.swp 8 | profile 9 | 10 | DerivedData/ 11 | build/ 12 | GeneratedPluginRegistrant.h 13 | GeneratedPluginRegistrant.m 14 | 15 | .generated/ 16 | 17 | *.pbxuser 18 | *.mode1v3 19 | *.mode2v3 20 | *.perspectivev3 21 | 22 | !default.pbxuser 23 | !default.mode1v3 24 | !default.mode2v3 25 | !default.perspectivev3 26 | 27 | xcuserdata 28 | 29 | *.moved-aside 30 | 31 | *.pyc 32 | *sync/ 33 | Icon? 34 | .tags* 35 | 36 | /Flutter/Generated.xcconfig 37 | -------------------------------------------------------------------------------- /ios/Assets/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codemonarch/flutter_ktport/c9755624e5d51348be873bd1ad6561cab9453fae/ios/Assets/.gitkeep -------------------------------------------------------------------------------- /ios/Classes/KtflutterPlugin.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface KtflutterPlugin : NSObject 4 | @end 5 | -------------------------------------------------------------------------------- /ios/Classes/KtflutterPlugin.m: -------------------------------------------------------------------------------- 1 | #import "KtflutterPlugin.h" 2 | #import 3 | 4 | @implementation KtflutterPlugin 5 | + (void)registerWithRegistrar:(NSObject*)registrar { 6 | [SwiftKtflutterPlugin registerWithRegistrar:registrar]; 7 | } 8 | @end 9 | -------------------------------------------------------------------------------- /ios/Classes/SwiftKtflutterPlugin.swift: -------------------------------------------------------------------------------- 1 | import Flutter 2 | import UIKit 3 | 4 | public func nativeRouting(block:(_ r: SwiftKtflutterPlugin.Type) -> Void) { 5 | block(SwiftKtflutterPlugin.self) 6 | } 7 | 8 | public class SwiftKtflutterPlugin: NSObject, FlutterPlugin { 9 | private static let channelName = "com.rarnu.flutter/routing" 10 | private static var channelList = [String: (params: [String: Any?]) -> Any?]() 11 | 12 | public static func register(with registrar: FlutterPluginRegistrar) { 13 | FlutterMethodChannel.init(name: channelName, binaryMessenger: registrar.messenger()).setMethodCallHandler { (call, result) in 14 | switch(call.method) { 15 | case "platform": 16 | result("iOS"); 17 | break 18 | case "app_version_code": 19 | result(Bundle.main.infoDictionary!["CFBundleShortVersionString"] as! String) 20 | break 21 | case "app_version_name": 22 | result(Bundle.main.infoDictionary!["CFBundleVersion"] as! String) 23 | break 24 | case "app_bundle": 25 | result(Bundle.main.infoDictionary!["CFBundleIdentifier"] as! String) 26 | break 27 | case "device_version": 28 | result(UIDevice.current.systemVersion) 29 | break 30 | case "device_model": 31 | result(UIDevice.current.systemName) 32 | break 33 | case "device_id": 34 | result(UIDevice.current.identifierForVendor?.uuidString) 35 | break 36 | case "device_document_path": 37 | let path = NSSearchPathForDirectoriesInDomains(FileManager.SearchPathDirectory.documentDirectory, FileManager.SearchPathDomainMask.allDomainsMask, true)[0] 38 | if (!FileManager.default.fileExists(atPath: path)) { 39 | do { 40 | try FileManager.default.createDirectory(atPath: path, withIntermediateDirectories: true, attributes: nil) 41 | } catch { 42 | 43 | } 44 | } 45 | result(path) 46 | break 47 | case "device_file_path": 48 | let path = NSSearchPathForDirectoriesInDomains(FileManager.SearchPathDirectory.documentDirectory, FileManager.SearchPathDomainMask.allDomainsMask, true)[0] + "/files" 49 | if (!FileManager.default.fileExists(atPath: path)) { 50 | do { 51 | try FileManager.default.createDirectory(atPath: path, withIntermediateDirectories: true, attributes: nil) 52 | } catch { 53 | 54 | } 55 | } 56 | result(path) 57 | break 58 | case "device_cache_path": 59 | let path = NSSearchPathForDirectoriesInDomains(FileManager.SearchPathDirectory.cachesDirectory, FileManager.SearchPathDomainMask.allDomainsMask, true)[0] 60 | if (!FileManager.default.fileExists(atPath: path)) { 61 | do { 62 | try FileManager.default.createDirectory(atPath: path, withIntermediateDirectories: true, attributes: nil) 63 | } catch { 64 | 65 | } 66 | } 67 | result(path) 68 | break 69 | default: 70 | let m = channelList[call.method] 71 | if (m != nil) { 72 | result(m!(call.arguments as! [String: Any?])) 73 | } else { 74 | result(nil) 75 | } 76 | } 77 | } 78 | } 79 | 80 | public class func route(_ name: String, block: @escaping(_ params: [String: Any?]) -> Any?) { 81 | channelList[name] = block 82 | } 83 | 84 | public class func routeList(_ name: String, block: @escaping(_ params: [String: Any?]) -> [Any?]?) { 85 | channelList[name] = block 86 | } 87 | 88 | public class func routeMap(_ name: String, block: @escaping(_ params: [String: Any?]) -> [AnyHashable: Any?]?) { 89 | channelList[name] = block 90 | } 91 | public class func routeObj(_ name: String, block: @escaping(_ params: [String: Any?]) -> [String: Any?]?) { 92 | channelList[name] = block 93 | } 94 | public class func routeObjList(_ name: String, block:@escaping(_ params:[String: Any?]) -> [[String: Any?]]?) { 95 | channelList[name] = block 96 | } 97 | public class func routeObjMap(_ name: String, block:@escaping(_ params: [String: Any?]) -> [AnyHashable: [String: Any?]]?) { 98 | channelList[name] = block 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /ios/ktflutter.podspec: -------------------------------------------------------------------------------- 1 | # 2 | # To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html 3 | # 4 | Pod::Spec.new do |s| 5 | s.name = 'ktflutter' 6 | s.version = '0.0.1' 7 | s.summary = 'A new flutter plugin project.' 8 | s.description = <<-DESC 9 | A new flutter plugin project. 10 | DESC 11 | s.homepage = 'http://example.com' 12 | s.license = { :file => '../LICENSE' } 13 | s.author = { 'Your Company' => 'email@example.com' } 14 | s.source = { :path => '.' } 15 | s.source_files = 'Classes/**/*' 16 | s.public_header_files = 'Classes/**/*.h' 17 | s.dependency 'Flutter' 18 | 19 | s.ios.deployment_target = '8.0' 20 | end 21 | 22 | -------------------------------------------------------------------------------- /ktflutter.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /lib/download_extension.dart: -------------------------------------------------------------------------------- 1 | import 'dart:io'; 2 | 3 | import 'package:ktflutter/string_extension.dart'; 4 | 5 | enum DownloadState { Start, Progress, Complete, Error } 6 | 7 | typedef DownloadCallback = void Function( 8 | DownloadState state, int position, int filesize, String error); 9 | 10 | Future download( 11 | String url, String localFile, DownloadCallback callback) async { 12 | File fTmp = File(localFile); 13 | if (fTmp.existsSync()) { 14 | fTmp.deleteSync(); 15 | } 16 | String strFolder = stringOf(localFile).substringBeforeLast('/').toString(); 17 | Directory fFolder = Directory(strFolder); 18 | if (!fFolder.existsSync()) { 19 | fFolder.createSync(recursive: true); 20 | } 21 | 22 | var isDownloadSuccess = true; 23 | try { 24 | HttpClient client = HttpClient(); 25 | client.connectionTimeout = Duration(seconds: 5); 26 | 27 | HttpClientRequest request = await client.getUrl(Uri.parse(url)); 28 | HttpClientResponse response = await request.close(); 29 | int filesize = response.contentLength; 30 | 31 | if (callback != null) callback(DownloadState.Start, 0, filesize, null); 32 | 33 | File fileOut = File('$localFile.tmp'); 34 | if (fileOut.existsSync()) { 35 | fileOut.deleteSync(); 36 | } 37 | 38 | int position = 0; 39 | response.listen((data) { 40 | int count = data.length; 41 | try { 42 | fileOut.writeAsBytesSync(data, mode: FileMode.append); 43 | position += count; 44 | if (callback != null) 45 | callback(DownloadState.Progress, position, filesize, null); 46 | } on Exception catch (exeption) { 47 | if (callback != null) 48 | callback(DownloadState.Error, 0, 0, exeption.toString()); 49 | } 50 | }, onDone: () { 51 | fileOut.renameSync(localFile); 52 | callback(DownloadState.Complete, 0, filesize, null); 53 | }, onError: (error) { 54 | isDownloadSuccess = false; 55 | if (callback != null) 56 | callback(DownloadState.Error, 0, 0, error.toString()); 57 | }, cancelOnError: true); 58 | } on Error catch (error) { 59 | print(error); 60 | isDownloadSuccess = false; 61 | if (callback != null) callback(DownloadState.Error, 0, 0, error.toString()); 62 | } on Exception catch (exception) { 63 | print(exception); 64 | isDownloadSuccess = false; 65 | if (callback != null) 66 | callback(DownloadState.Error, 0, 0, exception.toString()); 67 | } 68 | return isDownloadSuccess; 69 | } 70 | -------------------------------------------------------------------------------- /lib/global_extension.dart: -------------------------------------------------------------------------------- 1 | // run 2 | import 'package:ktflutter/route_extension.dart'; 3 | 4 | T krun(T block()) => block(); 5 | 6 | // repeat 7 | krepeat(int times, void action(int)) { 8 | for (int i = 0; i < times; i++) { 9 | action(i); 10 | } 11 | } 12 | 13 | T kalso(T t, void block(T obj)) { 14 | block(t); 15 | return t; 16 | } 17 | 18 | R klet(T t, R block(T obj)) => block(t); 19 | 20 | abstract class KMixin { 21 | T also(void block(T obj)) { 22 | block(this as T); 23 | return this as T; 24 | } 25 | 26 | R let(R block(T obj)) => block(this as T); 27 | T takeIf(bool block(T obj)) => block(this as T) ? this as T : null; 28 | T takeUnless(bool block(T obj)) => !block(this as T) ? this as T : null; 29 | } 30 | 31 | platform(void block(String s)) async => 32 | block(await posix.invokeMethod("platform", {})); 33 | appVersionCode(void block(String s)) async => 34 | block(await posix.invokeMethod("app_version_code", {})); 35 | appVersionName(void block(String s)) async => 36 | block(await posix.invokeMethod("app_version_name", {})); 37 | deviceVersion(void block(String s)) async => 38 | block(await posix.invokeMethod("device_version", {})); 39 | deviceModel(void block(String s)) async => 40 | block(await posix.invokeMethod("device_model", {})); 41 | deviceId(void block(String s)) async => 42 | block(await posix.invokeMethod("device_id", {})); 43 | 44 | // ios only 45 | appBundle(void block(String s)) => platform((p) async { 46 | block(p == "iOS" 47 | ? (await posix.invokeMethod("app_bundle", {})) 48 | : ""); 49 | }); 50 | 51 | // android only 52 | appPackage(void block(String s)) => platform((p) async { 53 | block(p == "Android" 54 | ? (await posix.invokeMethod("app_package", {})) 55 | : ""); 56 | }); 57 | 58 | deviceDocumentPath(void block(String path)) async => 59 | block(await posix.invokeMethod("device_document_path", {})); 60 | deviceFilePath(void block(String path)) async => 61 | block(await posix.invokeMethod("device_file_path", {})); 62 | deviceCachePath(void block(String path)) async => 63 | block(await posix.invokeMethod("device_cache_path", {})); 64 | 65 | // android only 66 | deviceExternalPath(void block(String path)) => platform((p) async { 67 | block(p == "Android" 68 | ? (await posix.invokeMethod("device_external_path", {})) 69 | : ""); 70 | }); 71 | deviceExternalDocumentPath(void block(String path)) => platform((p) async { 72 | block(p == "Android" 73 | ? (await posix 74 | .invokeMethod("device_external_document_path", {})) 75 | : ""); 76 | }); 77 | deviceExternalFilePath(void block(String path)) => platform((p) async { 78 | block(p == "Android" 79 | ? (await posix.invokeMethod("device_external_file_path", {})) 80 | : ""); 81 | }); 82 | deviceExternalCachePath(void block(String path)) => platform((p) async { 83 | block(p == "Android" 84 | ? (await posix.invokeMethod("device_external_cache_path", {})) 85 | : ""); 86 | }); 87 | deviceObbPath(void block(String path)) => platform((p) async { 88 | block(p == "Android" 89 | ? (await posix.invokeMethod("device_obb_path", {})) 90 | : ""); 91 | }); 92 | -------------------------------------------------------------------------------- /lib/http_extension.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | import 'dart:convert'; 3 | import 'dart:io'; 4 | 5 | import 'package:ktflutter/map_extension.dart'; 6 | import 'package:ktflutter/string_extension.dart'; 7 | 8 | enum HttpMethod { GET, HEAD, POST, PUT, DELETE } 9 | 10 | // http response 11 | class HttpResponse { 12 | final int status; 13 | final String body; 14 | 15 | HttpResponse(this.status, this.body); 16 | 17 | @override 18 | String toString() { 19 | return "$status, $body"; 20 | } 21 | } 22 | 23 | // http error, etc. timeout, 503 24 | class HttpError extends Error { 25 | int code; 26 | String message; 27 | HttpError([this.code, this.message]); 28 | 29 | @override 30 | String toString() { 31 | return "$code, $message"; 32 | } 33 | } 34 | 35 | // common http 36 | Future http(String url, HttpMethod method, 37 | {Map param, 38 | String mimeType = 'application/json', 39 | String body, 40 | Map postParam, 41 | Map fileParam, 42 | Map headers, 43 | int timeout = 15}) async { 44 | assert(url.isNotEmpty); 45 | Uri uri = Uri.parse(_buildUrl(url, _buildQueryStr(param))); 46 | try { 47 | HttpClient client = HttpClient(); 48 | client.connectionTimeout = Duration(seconds: timeout); 49 | HttpClientRequest request = await _buildRequest(client, uri, method); 50 | _assembleRequest(request, mimeType, headers, body, postParam, fileParam); 51 | HttpClientResponse response = await request.close(); 52 | var result = await response.transform(utf8.decoder).join(); 53 | return HttpResponse(response.statusCode, result); 54 | } on Error catch (error) { 55 | throw HttpError(-1, error.toString()); 56 | } on Exception catch (exception) { 57 | throw HttpError(-1, exception.toString()); 58 | } 59 | } 60 | 61 | // GET 62 | Future httpGet(String url, 63 | {Map param, Map headers}) async => 64 | http(url, HttpMethod.GET, param: param, headers: headers); 65 | 66 | // POST 67 | Future httpPost(String url, 68 | {Map param, 69 | String body, 70 | Map headers}) async => 71 | http(url, HttpMethod.POST, param: param, body: body, headers: headers); 72 | 73 | // build HttpClientRequest 74 | Future _buildRequest( 75 | HttpClient client, Uri uri, HttpMethod method) async { 76 | Future request; 77 | switch (method) { 78 | case HttpMethod.GET: 79 | request = client.getUrl(uri); 80 | break; 81 | case HttpMethod.POST: 82 | request = client.postUrl(uri); 83 | break; 84 | case HttpMethod.PUT: 85 | request = client.putUrl(uri); 86 | break; 87 | case HttpMethod.DELETE: 88 | request = client.deleteUrl(uri); 89 | break; 90 | case HttpMethod.HEAD: 91 | request = client.headUrl(uri); 92 | break; 93 | } 94 | return request; 95 | } 96 | 97 | void _assembleRequest(HttpClientRequest request, 98 | [String mimeType, 99 | Map headers, 100 | String body, 101 | Map param, 102 | Map file]) { 103 | if (request == null) { 104 | return; 105 | } 106 | 107 | // assemble headers 108 | if (headers != null) { 109 | headers.forEach((k, v) { 110 | request.headers.add(k, v); 111 | }); 112 | } 113 | 114 | // assemble body 115 | if (body != null) { 116 | request.headers.contentType = ContentType.parse(mimeType); 117 | request.write(body); 118 | } else { 119 | if (file != null) { 120 | // upload file 121 | const BOUNDARY_STR = "--"; 122 | const RANDOM_ID_STR = "_hjreq_"; 123 | request.headers.contentType = 124 | ContentType.parse('multipart/form-data; boundary=$RANDOM_ID_STR'); 125 | if (param != null) { 126 | param.forEach((k, v) { 127 | request.write('$BOUNDARY_STR$RANDOM_ID_STR\r\n'); 128 | request.write('Content-Disposition:form-data; name=\"$k\"\r\n\r\n'); 129 | request.write('$v\r\n'); 130 | }); 131 | } 132 | file.forEach((uploadId, uploadFile) { 133 | request.write('$BOUNDARY_STR$RANDOM_ID_STR\r\n'); 134 | var file = File(uploadFile); 135 | var filename = stringOf(uploadFile).lastPathPart(); 136 | request.write( 137 | 'Content-Disposition: form-data; name=\"$uploadId\"; filename=\"$filename\"\r\nContent-Type: application/octet-stream\r\n\r\n'); 138 | request.write(file.readAsBytesSync()); 139 | request.write('\r\n'); 140 | }); 141 | request.write('$BOUNDARY_STR$RANDOM_ID_STR$BOUNDARY_STR\r\n'); 142 | } else if (param != null) { 143 | // param transform k1=v1&k2=v2&... 144 | param.forEach((k, v) { 145 | request.write('$k=$v&'); 146 | }); 147 | } 148 | } 149 | } 150 | 151 | // concat url and query 152 | String _buildUrl(String url, String query) => (query == null || query.isEmpty) 153 | ? url 154 | : (url.contains("?") ? '$url&$query' : '$url?$query'); 155 | 156 | // map to query string 157 | String _buildQueryStr(Map params) => params == null 158 | ? null 159 | : mapOf(params) 160 | .mapToList((it) => "${it.key}=${it.value}") 161 | .joinToString("&") 162 | .toString(); 163 | -------------------------------------------------------------------------------- /lib/ktflutter.dart: -------------------------------------------------------------------------------- 1 | /** 2 | * entry of ktflutter 3 | */ 4 | -------------------------------------------------------------------------------- /lib/list_extension.dart: -------------------------------------------------------------------------------- 1 | import 'dart:collection'; 2 | 3 | import 'package:ktflutter/global_extension.dart'; 4 | import 'package:ktflutter/map_extension.dart'; 5 | import 'package:ktflutter/pair_extension.dart'; 6 | 7 | import 'package:ktflutter/string_extension.dart'; 8 | 9 | class KFList extends ListBase { 10 | // base 11 | List _innerList = new List(); 12 | int get length => _innerList.length; 13 | set length(int length) => _innerList.length = length; 14 | operator []=(int index, E value) => _innerList[index] = value; 15 | E operator [](int index) => _innerList[index]; 16 | List toFlutterList() => _innerList; 17 | 18 | // kotlin 19 | KFList also(void block(KFList list)) { 20 | block(this); 21 | return this; 22 | } 23 | 24 | R let(R block(KFList list)) => block(this); 25 | KFList takeIf(bool block(KFList list)) => block(this) ? this : null; 26 | KFList takeUnless(bool block(KFList list)) => 27 | !block(this) ? this : null; 28 | 29 | // find 30 | E find(bool block(E obj)) { 31 | for (var element in _innerList) { 32 | if (block(element)) { 33 | return element; 34 | } 35 | } 36 | return null; 37 | } 38 | 39 | // findLast 40 | E findLast(bool block(E obj)) { 41 | for (int i = length - 1; i >= 0; i--) { 42 | if (block(_innerList[i])) { 43 | return _innerList[i]; 44 | } 45 | } 46 | return null; 47 | } 48 | 49 | // indexOfFirst 50 | int indexOfFirst(bool block(E obj)) { 51 | var idx = -1; 52 | for (int i = 0; i < length; i++) { 53 | if (block(_innerList[i])) { 54 | idx = i; 55 | break; 56 | } 57 | } 58 | return idx; 59 | } 60 | 61 | // indexOfLast 62 | int indexOfLast(bool block(E obj)) { 63 | var idx = -1; 64 | for (int i = length - 1; i >= 0; i--) { 65 | if (block(_innerList[i])) { 66 | idx = i; 67 | break; 68 | } 69 | } 70 | return idx; 71 | } 72 | 73 | // drop 74 | KFList drop(int n) { 75 | var ret = KFList(); 76 | for (int i = n; i < length; i++) { 77 | ret.add(_innerList[i]); 78 | } 79 | return ret; 80 | } 81 | 82 | // dropLast 83 | KFList dropLast(int n) { 84 | var ret = KFList(); 85 | for (int i = 0; i < length - n; i++) { 86 | ret.add(_innerList[i]); 87 | } 88 | return ret; 89 | } 90 | 91 | // filter 92 | KFList filter(bool block(E obj)) { 93 | var ret = KFList(); 94 | for (int i = 0; i < length; i++) { 95 | if (block(_innerList[i])) ret.add(_innerList[i]); 96 | } 97 | return ret; 98 | } 99 | 100 | // filterIndexed 101 | KFList filterIndexed(bool block(int idx, E obj)) { 102 | var ret = KFList(); 103 | for (int i = 0; i < length; i++) { 104 | if (block(i, _innerList[i])) ret.add(_innerList[i]); 105 | } 106 | return ret; 107 | } 108 | 109 | // filterNot 110 | KFList filterNot(bool block(E obj)) { 111 | var ret = KFList(); 112 | for (int i = 0; i < length; i++) { 113 | if (!block(_innerList[i])) ret.add(_innerList[i]); 114 | } 115 | return ret; 116 | } 117 | 118 | // slice 119 | KFList slice(int startIdx, int endIdx) => 120 | listOf(_innerList.sublist(startIdx, endIdx)); 121 | 122 | // sortBy 123 | KFList sortBy(int block(E first, E second)) => 124 | klet, KFList>(listOf(_innerList), (tmp) { 125 | tmp._innerList.sort(block); 126 | return listOf(tmp); 127 | }); 128 | 129 | // sortByDescending 130 | KFList sortByDescending(int block(E first, E second)) => 131 | klet, KFList>(listOf(_innerList), (tmp) { 132 | tmp._innerList.sort(block); 133 | return listOf(tmp.reversed.toList()); 134 | }); 135 | 136 | // map/override 137 | KFList map(T block(E obj)) => 138 | KFList().also((it) => it.addAll(super.map(block))); 139 | 140 | // mapIndexed 141 | KFList mapIndexed(T block(int idx, E obj)) { 142 | var ret = KFList(); 143 | for (int i = 0; i < length; i++) { 144 | ret.add(block(i, _innerList[i])); 145 | } 146 | return ret; 147 | } 148 | 149 | // distinct 150 | KFList distinct() { 151 | var ret = KFList(); 152 | for (var item in _innerList) { 153 | if (!ret.contains(item)) { 154 | ret.add(item); 155 | } 156 | } 157 | return ret; 158 | } 159 | 160 | // distinctBy 161 | KFList distinctBy(K block(E obj)) { 162 | var set = HashSet(); 163 | var list = KFList(); 164 | for (var e in _innerList) { 165 | var key = block(e); 166 | if (set.add(key)) { 167 | list.add(e); 168 | } 169 | } 170 | return list; 171 | } 172 | 173 | // all 174 | bool all(bool block(E obj)) { 175 | if (_innerList.isEmpty) return false; 176 | for (var item in _innerList) { 177 | if (!block(item)) { 178 | return false; 179 | } 180 | } 181 | return true; 182 | } 183 | 184 | // any 185 | bool any(bool block(E obj)) { 186 | if (_innerList.isEmpty) return false; 187 | for (var item in _innerList) { 188 | if (block(item)) { 189 | return true; 190 | } 191 | } 192 | return false; 193 | } 194 | 195 | // count 196 | int count(bool block(E obj)) { 197 | var ret = 0; 198 | for (var item in _innerList) { 199 | if (block(item)) { 200 | ret++; 201 | } 202 | } 203 | return ret; 204 | } 205 | 206 | // forEachIndexed/new 207 | forEachIndexed(void action(int index, E element)) { 208 | for (int i = 0; i < this.length; i++) { 209 | action(i, this[i]); 210 | } 211 | } 212 | 213 | // none 214 | bool none(bool block(E obj)) { 215 | if (_innerList.isEmpty) return true; 216 | for (var item in _innerList) { 217 | if (block(item)) { 218 | return false; 219 | } 220 | } 221 | return true; 222 | } 223 | 224 | // reduceIndexed 225 | E reduceIndexed(E oper(int idx, E acc, E s)) { 226 | var accumulator = _innerList[0]; 227 | for (int i = 1; i < length; i++) { 228 | accumulator = oper(i, accumulator, _innerList[i]); 229 | } 230 | return accumulator; 231 | } 232 | 233 | // minus 234 | minus(Object obj) { 235 | var tmp = obj is List ? obj : (obj is KFList ? obj._innerList : null); 236 | _innerList.removeWhere((it) => tmp.contains(it)); 237 | } 238 | 239 | // joinToString 240 | KFString joinToString([String sep = ","]) { 241 | var str = ""; 242 | _innerList.forEach((it) => str += "$it$sep"); 243 | if (str.endsWith(sep)) { 244 | str = str.substring(0, str.length - sep.length); 245 | } 246 | return KFString(str); 247 | } 248 | 249 | KFList toStringList() { 250 | var ret = KFList(); 251 | for (var item in _innerList) { 252 | ret.add("$item"); 253 | } 254 | return ret; 255 | } 256 | 257 | KFMap toMap() { 258 | var ret = KFMap(); 259 | if (_innerList is List>) { 260 | for (var item in _innerList) { 261 | var m = item as KFPair; 262 | ret[m.left] = m.right; 263 | } 264 | } 265 | return ret; 266 | } 267 | 268 | // mapTo 269 | C mapTo>(C dest, R block(E obj)) { 270 | for (var item in this) { 271 | dest.add(block(item)); 272 | } 273 | return dest; 274 | } 275 | 276 | // mapIndexedTo 277 | C mapIndexedTo>(C dest, R block(int idx, E obj)) { 278 | for (int i = 0; i < length; i++) { 279 | dest.add(block(i, _innerList[i])); 280 | } 281 | return dest; 282 | } 283 | 284 | // filterTo 285 | C filterTo>(C dest, bool block(E obj)) { 286 | for (var item in this) { 287 | if (block(item)) { 288 | dest.add(item); 289 | } 290 | } 291 | return dest; 292 | } 293 | 294 | // filterIndexedTo 295 | C filterIndexedTo>(C dest, bool block(int idx, E obj)) { 296 | for (int i = 0; i < length; i++) { 297 | if (block(i, _innerList[i])) { 298 | dest.add(_innerList[i]); 299 | } 300 | } 301 | return dest; 302 | } 303 | 304 | // filterNotTo 305 | C filterNotTo>(C dest, bool block(E obj)) { 306 | for (var item in this) { 307 | if (!block(item)) { 308 | dest.add(item); 309 | } 310 | } 311 | return dest; 312 | } 313 | } 314 | 315 | KFList listOf(Iterable list) => 316 | KFList().also((it) => it.addAll(list)); 317 | -------------------------------------------------------------------------------- /lib/map_extension.dart: -------------------------------------------------------------------------------- 1 | import 'dart:collection'; 2 | 3 | import 'package:ktflutter/list_extension.dart'; 4 | import 'package:ktflutter/pair_extension.dart'; 5 | 6 | class KFMap extends MapBase { 7 | // base 8 | Map _innerMap = new Map(); 9 | V operator [](Object key) => _innerMap[key]; 10 | void operator []=(K key, V value) => _innerMap[key] = value; 11 | void clear() => _innerMap.clear(); 12 | Iterable get keys => _innerMap.keys; 13 | V remove(Object key) => _innerMap.remove(key); 14 | 15 | // kotlin 16 | KFMap also(void block(KFMap map)) { 17 | block(this); 18 | return this; 19 | } 20 | 21 | R let(R block(KFMap list)) => block(this); 22 | KFMap takeIf(bool block(KFMap list)) => block(this) ? this : null; 23 | KFMap takeUnless(bool block(KFMap list)) => 24 | !block(this) ? this : null; 25 | 26 | // toList() 27 | KFList> toList() { 28 | var ret = KFList>(); 29 | _innerMap.forEach((k, v) => ret.add(KFPair(k, v))); 30 | return ret; 31 | } 32 | 33 | // mapToList 34 | KFList mapToList(R block(MapEntry e)) { 35 | var ret = KFList(); 36 | _innerMap.forEach((k, v) => ret.add(block(MapEntry(k, v)))); 37 | return ret; 38 | } 39 | 40 | // forEachEntry 41 | forEachEntry(void block(MapEntry e)) => 42 | _innerMap.forEach((k, v) => block(MapEntry(k, v))); 43 | 44 | // all 45 | bool all(bool block(MapEntry e)) { 46 | if (_innerMap.isEmpty) return false; 47 | var ret = true; 48 | forEachEntry((it) { 49 | if (!block(it)) ret = false; 50 | }); 51 | return ret; 52 | } 53 | 54 | // public inline fun Map.any(predicate: (Map.Entry) -> Boolean): Boolean 55 | bool any(bool block(MapEntry e)) { 56 | if (_innerMap.isEmpty) return false; 57 | var ret = false; 58 | forEachEntry((it) { 59 | if (block(it)) ret = true; 60 | }); 61 | return ret; 62 | } 63 | 64 | // count 65 | int count(bool block(MapEntry e)) { 66 | var ret = 0; 67 | forEachEntry((it) { 68 | if (block(it)) ret++; 69 | }); 70 | return ret; 71 | } 72 | 73 | // none 74 | bool none(bool block(MapEntry e)) { 75 | if (_innerMap.isEmpty) return true; 76 | var ret = true; 77 | forEachEntry((it) { 78 | if (block(it)) ret = false; 79 | }); 80 | return ret; 81 | } 82 | 83 | // filterKeys 84 | KFMap filterKeys(bool block(K k)) { 85 | var ret = KFMap(); 86 | forEachEntry((it) { 87 | if (block(it.key)) ret[it.key] = it.value; 88 | }); 89 | return ret; 90 | } 91 | 92 | // filterValues 93 | KFMap filterValues(bool block(V v)) { 94 | var ret = KFMap(); 95 | forEachEntry((it) { 96 | if (block(it.value)) ret[it.key] = it.value; 97 | }); 98 | return ret; 99 | } 100 | 101 | // filter 102 | KFMap filter(bool block(MapEntry e)) { 103 | var ret = KFMap(); 104 | forEachEntry((it) { 105 | if (block(it)) ret[it.key] = it.value; 106 | }); 107 | return ret; 108 | } 109 | 110 | // filterNot 111 | KFMap filterNot(bool block(MapEntry e)) { 112 | var ret = KFMap(); 113 | forEachEntry((it) { 114 | if (!block(it)) ret[it.key] = it.value; 115 | }); 116 | return ret; 117 | } 118 | 119 | // add 120 | add(Object obj) { 121 | var tmp = 122 | obj is Map ? obj : (obj is KFMap ? obj._innerMap : null); 123 | tmp.forEach((k, v) => _innerMap[k] = v); 124 | } 125 | 126 | // minus 127 | minus(Object obj) { 128 | var tmp = 129 | obj is Map ? obj : (obj is KFMap ? obj._innerMap : null); 130 | _innerMap.removeWhere((k, v) => tmp[k] == v); 131 | } 132 | 133 | // filterTo 134 | KFMap filterTo>( 135 | M dest, bool block(MapEntry e)) { 136 | forEachEntry((it) { 137 | if (block(it)) { 138 | dest[it.key] = it.value; 139 | } 140 | }); 141 | return mapOf(dest); 142 | } 143 | 144 | // filterNotTo 145 | KFMap filterNotTo>( 146 | M dest, bool block(MapEntry e)) { 147 | forEachEntry((it) { 148 | if (!block(it)) { 149 | dest[it.key] = it.value; 150 | } 151 | }); 152 | return mapOf(dest); 153 | } 154 | 155 | // filterKeysTo 156 | KFMap filterKeysTo>(M dest, bool block(K k)) { 157 | forEachEntry((it) { 158 | if (block(it.key)) { 159 | dest[it.key] = it.value; 160 | } 161 | }); 162 | return mapOf(dest); 163 | } 164 | 165 | // filterValuesTo 166 | KFMap filterValuesTo>(M dest, bool block(V v)) { 167 | forEachEntry((it) { 168 | if (block(it.value)) { 169 | dest[it.key] = it.value; 170 | } 171 | }); 172 | return mapOf(dest); 173 | } 174 | 175 | // mapTo 176 | KFMap mapTo>( 177 | C dest, MapEntry block(MapEntry e)) { 178 | forEachEntry((it) { 179 | var item = block(it); 180 | dest[item.key] = item.value; 181 | }); 182 | return mapOf(dest); 183 | } 184 | 185 | // mapToListTo 186 | KFList mapToListTo>( 187 | C dest, R block(MapEntry e)) { 188 | forEachEntry((it) { 189 | dest.add(block(it)); 190 | }); 191 | return listOf(dest); 192 | } 193 | 194 | // mapKeysTo 195 | KFMap mapKeysTo>( 196 | C dest, MapEntry block(K k)) { 197 | forEachEntry((it) { 198 | var item = block(it.key); 199 | dest[item.key] = item.value; 200 | }); 201 | return mapOf(dest); 202 | } 203 | 204 | // mapKeysToListTo 205 | KFList mapKeysToListTo>(C dest, R block(K k)) { 206 | _innerMap.forEach((k, v) { 207 | dest.add(block(k)); 208 | }); 209 | return listOf(dest); 210 | } 211 | 212 | // mapValuesTo 213 | KFMap mapValuesTo>( 214 | C dest, MapEntry block(V v)) { 215 | forEachEntry((it) { 216 | var item = block(it.value); 217 | dest[item.key] = item.value; 218 | }); 219 | return mapOf(dest); 220 | } 221 | 222 | // mapValuesToListTo 223 | KFList mapValuesToListTo>(C dest, R block(V v)) { 224 | _innerMap.forEach((k, v) { 225 | dest.add(block(v)); 226 | }); 227 | return listOf(dest); 228 | } 229 | } 230 | 231 | KFMap mapOf(Map map) => 232 | KFMap().also((it) => it.addAll(map)); 233 | -------------------------------------------------------------------------------- /lib/pair_extension.dart: -------------------------------------------------------------------------------- 1 | import 'package:ktflutter/list_extension.dart'; 2 | 3 | class KFPair { 4 | KFPair(this.left, this.right); 5 | 6 | final T left; 7 | final U right; 8 | String toString() => 'Pair[$left, $right]'; 9 | KFList toList() => U is T ? listOf([left, right as T]) : null; 10 | } 11 | 12 | class KFTriple { 13 | KFTriple(this.first, this.second, this.third); 14 | final A first; 15 | final B second; 16 | final C third; 17 | String toString() => 'Triple[$first, $second, $third]'; 18 | KFList toList() => 19 | (B is A && C is A) ? listOf([first, second as A, third as A]) : null; 20 | } 21 | -------------------------------------------------------------------------------- /lib/regex_extension.dart: -------------------------------------------------------------------------------- 1 | bool regexMatch(String str, String regex) => RegExp(regex).hasMatch(str); 2 | 3 | const _regNumbers = [ 4 | "^[0-9]*\$", // 数字 5 | "^([1-9][0-9]*)+(.[0-9]{1,2})?\$", // 非零开头的最多带两位小数的数字 6 | "^(\\-)?\\d+(\\.\\d{1,2})?\$", // 带1-2位小数的正数或负数 7 | "^(\\-|\\+)?\\d+(\\.\\d+)?\$", // 正数、负数、和小数 8 | "^[0-9]+(.[0-9]{2})?\$", // 有两位小数的正实数 9 | "^[0-9]+(.[0-9]{1,3})?\$", // 有1~3位小数的正实数 10 | "^[1-9]\\d*\$", // 非零的正整数 11 | "^-[1-9]\\d*\$", // 非零的负整数 12 | "^\\d+\$", // 非负整数 13 | "^-[1-9]\\d*|0\$", // 非正整数 14 | "^\\d+(\\.\\d+)?\$", // 非负浮点数 15 | "^((-\\d+(\\.\\d+)?)|(0+(\\.0+)?))\$", // 非正浮点数 16 | "^[1-9]\\d*\\.\\d*|0\\.\\d*[1-9]\\d*\$", // 正浮点数 17 | "^-([1-9]\\d*\\.\\d*|0\\.\\d*[1-9]\\d*)\$", // 负浮点数 18 | "^(-?\\d+)(\\.\\d+)?\$" // 浮点数 19 | ]; 20 | 21 | const _regStrings = [ 22 | "^[\\u4e00-\\u9fa5]{0,}\$", // 汉字 23 | "^[A-Za-z0-9]+\$", // 英文和数字 24 | "^[A-Za-z]+\$", // 由26个英文字母组成的字符串 25 | "^[A-Z]+\$", // 由26个大写英文字母组成的字符串 26 | "^[a-z]+\$", // 由26个小写英文字母组成的字符串 27 | "^[a-z0-9A-Z_]+\$", // 由数字、26个英文字母或者下划线组成的字符串 28 | "^[\\u4E00-\\u9FA5A-Za-z0-9_]+\$", // 中文、英文、数字包括下划线 29 | "^[\\u4E00-\\u9FA5A-Za-z0-9]+\$", // 中文、英文、数字但不包括下划线等符号 30 | "[^%&',;=?\$\\x22]+", // 可以输入含有^%&',;=?$\"等字符 31 | "[^~\\x22]+" // 含有~的字符 32 | ]; 33 | 34 | bool isStringReg(String str, int type) => regexMatch(str, _regStrings[type]); 35 | bool isNumberReg(String str, int type) => regexMatch(str, _regNumbers[type]); 36 | bool isEmail(String str) => 37 | regexMatch(str, "^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*\$"); 38 | bool isPhoneNumber(String str) => 39 | regexMatch(str, "^(\\(\\d{3,4}-)|\\d{3.4}-)?\\d{7,8}\$"); 40 | bool isCellPhoneNumber(String str) => regexMatch(str, 41 | "^(13[0-9]|14[5|7]|15[0|1|2|3|5|6|7|8|9]|18[0|1|2|3|5|6|7|8|9])\\d{8}\$"); 42 | bool isChinesePhoneNumber(String str) => 43 | regexMatch(str, "\\d{3}-\\d{8}|\\d{4}-\\d{7}"); 44 | bool isIdCardNumber(String str) => regexMatch(str, "^\\d{15}|\\d{18}\$"); 45 | bool isShortIdCardNumber(String str) => 46 | regexMatch(str, "^([0-9]){7,18}(x|X)?\$"); 47 | bool isUrl(String str) => regexMatch(str, "[a-zA-z]+://[^\\s]*"); 48 | bool isDomain(String str) => regexMatch( 49 | str, "[a-zA-Z0-9][-a-zA-Z0-9]{0,62}(/.[a-zA-Z0-9][-a-zA-Z0-9]{0,62})+/.?"); 50 | bool isValidAccount(String str) => 51 | regexMatch(str, "^[a-zA-Z][a-zA-Z0-9_]{5,31}\$"); 52 | bool isValidPassword(String str) => regexMatch(str, "^[a-zA-Z]\\w{5,31}\$"); 53 | bool isStrongPassword(String str) => 54 | regexMatch(str, "^(?=.*\\d)(?=.*[a-z])(?=.*[A-Z]).{8,10}\$"); 55 | bool isDate(String str) => regexMatch(str, "^\\d{4}-\\d{1,2}-\\d{1,2}"); 56 | bool isValidXml(String str) => 57 | regexMatch(str, "^([a-zA-Z]+-?)+[a-zA-Z0-9]+\\\\.[x|X][m|M][l|L]\$"); 58 | bool isBlankLine(String str) => regexMatch(str, "\\n\\s*\\r"); 59 | bool isValidHtml(String str) => 60 | regexMatch(str, "<(\\S*?)[^>]*>.*?|<.*? />"); 61 | bool isValidQQNumber(String str) => regexMatch(str, "[1-9][0-9]{4,}"); 62 | bool isValidPostCode(String str) => regexMatch(str, "[1-9]\\d{5}(?!\\d)"); 63 | bool isValidIPAddress(String str) => regexMatch(str, 64 | "((?:(?:25[0-5]|2[0-4]\\\\d|[01]?\\\\d?\\\\d)\\\\.){3}(?:25[0-5]|2[0-4]\\\\d|[01]?\\\\d?\\\\d))"); 65 | -------------------------------------------------------------------------------- /lib/route_extension.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/services.dart'; 2 | 3 | const posix = const MethodChannel('com.rarnu.flutter/routing'); 4 | route(String name, dynamic arguments, void block(T obj)) async => 5 | block(await posix.invokeMethod(name, arguments)); 6 | routeList(String name, dynamic arguments, void block(List list)) async => 7 | block(await posix.invokeListMethod(name, arguments)); 8 | routeMap( 9 | String name, dynamic arguments, void block(Map map)) async => 10 | block(await posix.invokeMapMethod(name, arguments)); 11 | routeObj(String name, dynamic arguments, T parse(dynamic p), 12 | void block(T obj)) async => 13 | block(parse(await posix.invokeMethod(name, arguments))); 14 | routeObjList(String name, dynamic arguments, T parse(dynamic p), 15 | void block(List list)) async => 16 | block((await posix.invokeListMethod(name, arguments)).map(parse).toList()); 17 | routeObjMap(String name, dynamic arguments, V parse(dynamic p), 18 | void block(Map map)) async => 19 | block((await posix.invokeMapMethod(name, arguments)) 20 | .map((k, v) => MapEntry(k, parse(v)))); 21 | -------------------------------------------------------------------------------- /lib/set_extension.dart: -------------------------------------------------------------------------------- 1 | import 'dart:collection'; 2 | 3 | import 'package:ktflutter/global_extension.dart'; 4 | import 'package:ktflutter/map_extension.dart'; 5 | import 'package:ktflutter/pair_extension.dart'; 6 | 7 | import 'package:ktflutter/string_extension.dart'; 8 | 9 | class KFSet extends SetBase { 10 | // base 11 | Set _innerSet = new Set(); 12 | int get length => _innerSet.length; 13 | E lookup(Object element) => _innerSet.lookup(element); 14 | bool add(E value) => _innerSet.add(value); 15 | bool contains(Object element) => _innerSet.contains(element); 16 | bool remove(Object value) => _innerSet.remove(value); 17 | Iterator get iterator => _innerSet.iterator; 18 | Set toSet() => _innerSet.toSet(); 19 | 20 | // kotlin 21 | KFSet also(void block(KFSet list)) { 22 | block(this); 23 | return this; 24 | } 25 | 26 | R let(R block(KFSet list)) => block(this); 27 | KFSet takeIf(bool block(KFSet list)) => block(this) ? this : null; 28 | KFSet takeUnless(bool block(KFSet list)) => !block(this) ? this : null; 29 | 30 | // find 31 | E find(bool block(E obj)) { 32 | for (var element in _innerSet) { 33 | if (block(element)) { 34 | return element; 35 | } 36 | } 37 | return null; 38 | } 39 | 40 | // findLast 41 | E findLast(bool block(E obj)) { 42 | for (int i = length - 1; i >= 0; i--) { 43 | if (block(_innerSet.elementAt(i))) { 44 | return _innerSet.elementAt(i); 45 | } 46 | } 47 | return null; 48 | } 49 | 50 | // indexOfFirst 51 | int indexOfFirst(bool block(E obj)) { 52 | var idx = -1; 53 | for (int i = 0; i < length; i++) { 54 | if (block(_innerSet.elementAt(i))) { 55 | idx = i; 56 | break; 57 | } 58 | } 59 | return idx; 60 | } 61 | 62 | // indexOfLast 63 | int indexOfLast(bool block(E obj)) { 64 | var idx = -1; 65 | for (int i = length - 1; i >= 0; i--) { 66 | if (block(_innerSet.elementAt(i))) { 67 | idx = i; 68 | break; 69 | } 70 | } 71 | return idx; 72 | } 73 | 74 | // drop 75 | KFSet drop(int n) { 76 | var ret = KFSet(); 77 | for (int i = n; i < length; i++) { 78 | ret.add(_innerSet.elementAt(i)); 79 | } 80 | return ret; 81 | } 82 | 83 | // dropLast 84 | KFSet dropLast(int n) { 85 | var ret = KFSet(); 86 | for (int i = 0; i < length - n; i++) { 87 | ret.add(_innerSet.elementAt(i)); 88 | } 89 | return ret; 90 | } 91 | 92 | // filter 93 | KFSet filter(bool block(E obj)) { 94 | var ret = KFSet(); 95 | for (int i = 0; i < length; i++) { 96 | if (block(_innerSet.elementAt(i))) ret.add(_innerSet.elementAt(i)); 97 | } 98 | return ret; 99 | } 100 | 101 | // filterIndexed 102 | KFSet filterIndexed(bool block(int idx, E obj)) { 103 | var ret = KFSet(); 104 | for (int i = 0; i < length; i++) { 105 | if (block(i, _innerSet.elementAt(i))) ret.add(_innerSet.elementAt(i)); 106 | } 107 | return ret; 108 | } 109 | 110 | // filterNot 111 | KFSet filterNot(bool block(E obj)) { 112 | var ret = KFSet(); 113 | for (int i = 0; i < length; i++) { 114 | if (!block(_innerSet.elementAt(i))) ret.add(_innerSet.elementAt(i)); 115 | } 116 | return ret; 117 | } 118 | 119 | // slice 120 | KFSet slice(int startIdx, int endIdx) { 121 | var ret = KFSet(); 122 | for (int i = startIdx; i < endIdx; i++) { 123 | ret.add(_innerSet.elementAt(i)); 124 | } 125 | return ret; 126 | } 127 | 128 | // sortBy 129 | KFSet sortBy(int block(E first, E second)) => 130 | klet, KFSet>(setOf(_innerSet), (tmp) { 131 | tmp._innerSet.toList().sort(block); 132 | return tmp; 133 | }); 134 | 135 | // sortByDescending 136 | KFSet sortByDescending(int block(E first, E second)) => 137 | klet, KFSet>(setOf(_innerSet), (tmp) { 138 | tmp._innerSet.toList().sort(block); 139 | return setOf(tmp.toList().reversed); 140 | }); 141 | 142 | // map/override 143 | KFSet map(T block(E obj)) => 144 | KFSet().also((it) => it.addAll(super.map(block))); 145 | 146 | // mapIndexed 147 | KFSet mapIndexed(T block(int idx, E obj)) { 148 | var ret = KFSet(); 149 | for (int i = 0; i < length; i++) { 150 | ret.add(block(i, _innerSet.elementAt(i))); 151 | } 152 | return ret; 153 | } 154 | 155 | // distinct 156 | KFSet distinct() { 157 | var ret = KFSet(); 158 | for (var item in _innerSet) { 159 | if (!ret.contains(item)) { 160 | ret.add(item); 161 | } 162 | } 163 | return ret; 164 | } 165 | 166 | // distinctBy 167 | KFSet distinctBy(K block(E obj)) { 168 | var set = HashSet(); 169 | var list = KFSet(); 170 | for (var e in _innerSet) { 171 | var key = block(e); 172 | if (set.add(key)) { 173 | list.add(e); 174 | } 175 | } 176 | return list; 177 | } 178 | 179 | // all 180 | bool all(bool block(E obj)) { 181 | if (_innerSet.isEmpty) return false; 182 | for (var item in _innerSet) { 183 | if (!block(item)) { 184 | return false; 185 | } 186 | } 187 | return true; 188 | } 189 | 190 | // any 191 | bool any(bool block(E obj)) { 192 | if (_innerSet.isEmpty) return false; 193 | for (var item in _innerSet) { 194 | if (block(item)) { 195 | return true; 196 | } 197 | } 198 | return false; 199 | } 200 | 201 | // count 202 | int count(bool block(E obj)) { 203 | var ret = 0; 204 | for (var item in _innerSet) { 205 | if (block(item)) { 206 | ret++; 207 | } 208 | } 209 | return ret; 210 | } 211 | 212 | // forEachIndexed/new 213 | forEachIndexed(void action(int index, E element)) { 214 | for (int i = 0; i < this.length; i++) { 215 | action(i, this.elementAt(i)); 216 | } 217 | } 218 | 219 | // none 220 | bool none(bool block(E obj)) { 221 | if (_innerSet.isEmpty) return true; 222 | for (var item in _innerSet) { 223 | if (block(item)) { 224 | return false; 225 | } 226 | } 227 | return true; 228 | } 229 | 230 | // reduceIndexed 231 | E reduceIndexed(E oper(int idx, E acc, E s)) { 232 | var accumulator = _innerSet.elementAt(0); 233 | for (int i = 1; i < length; i++) { 234 | accumulator = oper(i, accumulator, _innerSet.elementAt(i)); 235 | } 236 | return accumulator; 237 | } 238 | 239 | // minus 240 | minus(Object obj) { 241 | var tmp = obj is List ? obj : (obj is KFSet ? obj._innerSet : null); 242 | _innerSet.removeWhere((it) => tmp.contains(it)); 243 | } 244 | 245 | // joinToString 246 | KFString joinToString([String sep = ","]) { 247 | var str = ""; 248 | _innerSet.forEach((it) => str += "$it$sep"); 249 | if (str.endsWith(sep)) { 250 | str = str.substring(0, str.length - sep.length); 251 | } 252 | return KFString(str); 253 | } 254 | 255 | KFSet toStringList() { 256 | var ret = KFSet(); 257 | for (var item in _innerSet) { 258 | ret.add("$item"); 259 | } 260 | return ret; 261 | } 262 | 263 | KFMap toMap() { 264 | var ret = KFMap(); 265 | if (_innerSet is Set>) { 266 | for (var item in _innerSet) { 267 | var m = item as KFPair; 268 | ret[m.left] = m.right; 269 | } 270 | } 271 | return ret; 272 | } 273 | 274 | // mapTo 275 | C mapTo>(C dest, R block(E obj)) { 276 | for (var item in this) { 277 | dest.add(block(item)); 278 | } 279 | return dest; 280 | } 281 | 282 | // mapIndexedTo 283 | C mapIndexedTo>(C dest, R block(int idx, E obj)) { 284 | for (int i = 0; i < length; i++) { 285 | dest.add(block(i, _innerSet.elementAt(i))); 286 | } 287 | return dest; 288 | } 289 | 290 | // filterTo 291 | C filterTo>(C dest, bool block(E obj)) { 292 | for (var item in this) { 293 | if (block(item)) { 294 | dest.add(item); 295 | } 296 | } 297 | return dest; 298 | } 299 | 300 | // filterIndexedTo 301 | C filterIndexedTo>(C dest, bool block(int idx, E obj)) { 302 | for (int i = 0; i < length; i++) { 303 | if (block(i, _innerSet.elementAt(i))) { 304 | dest.add(_innerSet.elementAt(i)); 305 | } 306 | } 307 | return dest; 308 | } 309 | 310 | // filterNotTo 311 | C filterNotTo>(C dest, bool block(E obj)) { 312 | for (var item in this) { 313 | if (!block(item)) { 314 | dest.add(item); 315 | } 316 | } 317 | return dest; 318 | } 319 | } 320 | 321 | KFSet setOf(Iterable set) => KFSet().also((it) => it.addAll(set)); 322 | -------------------------------------------------------------------------------- /lib/string_extension.dart: -------------------------------------------------------------------------------- 1 | import 'dart:convert'; 2 | import 'dart:io'; 3 | import 'package:ktflutter/list_extension.dart'; 4 | import 'package:ktflutter/pair_extension.dart'; 5 | import 'package:ktflutter/global_extension.dart'; 6 | 7 | class KFString { 8 | // common 9 | KFString(this._innerString); 10 | 11 | String _innerString; 12 | String toString() => _innerString; 13 | 14 | // origin 15 | Iterable allMatches(Object string, [int start = 0]) => 16 | _innerString.allMatches( 17 | string is String 18 | ? string 19 | : (string is KFString ? string._innerString : ""), 20 | start); 21 | Match matchAsPrefix(Object string, 22 | [int start = 0]) => 23 | _innerString.matchAsPrefix( 24 | string is String 25 | ? string 26 | : (string is KFString ? string._innerString : ""), 27 | start); 28 | KFString operator [](int index) => KFString(_innerString[index]); 29 | int codeUnitAt(int index) => _innerString.codeUnitAt(index); 30 | int get length => _innerString.length; 31 | int get hashCode => _innerString.hashCode; 32 | bool operator ==(Object other) => other is String 33 | ? _innerString == other 34 | : (other is KFString ? _innerString == other._innerString : false); 35 | int compareTo(Object other) => _innerString.compareTo( 36 | other is String ? other : (other is KFString ? other._innerString : "")); 37 | bool endsWith(Object other) => _innerString.endsWith( 38 | other is String ? other : (other is KFString ? other._innerString : "")); 39 | bool startsWith(Pattern pattern, [int index = 0]) => 40 | _innerString.startsWith(pattern, index); 41 | int indexOf(Pattern pattern, [int start]) => start == null 42 | ? _innerString.indexOf(pattern) 43 | : _innerString.indexOf(pattern, start); 44 | int lastIndexOf(Pattern pattern, [int start]) => start == null 45 | ? _innerString.lastIndexOf(pattern) 46 | : _innerString.lastIndexOf(pattern, start); 47 | bool get isEmpty => _innerString.isEmpty; 48 | bool get isNotEmpty => _innerString.isNotEmpty; 49 | KFString operator +(Object other) => KFString(_innerString + 50 | (other is String 51 | ? other 52 | : (other is KFString ? other._innerString : ""))); 53 | KFString substring(int startIndex, [int endIndex]) => 54 | KFString(endIndex == null 55 | ? _innerString.substring(startIndex) 56 | : _innerString.substring(startIndex, endIndex)); 57 | KFString trim() => KFString(_innerString.trim()); 58 | KFString trimLeft() => KFString(_innerString.trimLeft()); 59 | KFString trimRight() => KFString(_innerString.trimRight()); 60 | KFString operator *(int times) => KFString(_innerString * times); 61 | KFString padLeft(int width, [Object padding = ' ']) => 62 | KFString(_innerString.padLeft( 63 | width, 64 | padding is String 65 | ? padding 66 | : (padding is KFString ? padding._innerString : ""))); 67 | KFString padRight(int width, [Object padding = ' ']) => 68 | KFString(_innerString.padRight( 69 | width, 70 | padding is String 71 | ? padding 72 | : (padding is KFString ? padding._innerString : ""))); 73 | bool contains(Pattern other, [int startIndex = 0]) => 74 | _innerString.contains(other, startIndex); 75 | KFString replaceFirst(Pattern from, Object to, [int startIndex = 0]) => 76 | KFString(_innerString.replaceFirst( 77 | from, 78 | to is String ? to : (to is KFString ? to._innerString : from), 79 | startIndex)); 80 | KFString replaceFirstMapped(Pattern from, String replace(Match match), 81 | [int startIndex = 0]) => 82 | KFString(_innerString.replaceFirstMapped(from, replace, startIndex)); 83 | KFString replaceAll(Pattern from, Object replace) => 84 | KFString(_innerString.replaceAll( 85 | from, 86 | replace is String 87 | ? replace 88 | : (replace is KFString ? replace._innerString : from))); 89 | KFString replaceAllMapped(Pattern from, String replace(Match match)) => 90 | KFString(_innerString.replaceAllMapped(from, replace)); 91 | KFString replaceRange(int start, int end, Object replacement) => 92 | KFString(_innerString.replaceRange( 93 | start, 94 | end, 95 | replacement is String 96 | ? replacement 97 | : (replacement is KFString ? replacement._innerString : ""))); 98 | KFList split(Pattern pattern) => 99 | listOf(_innerString.split(pattern).map((it) => KFString(it)).toList()); 100 | KFString splitMapJoin(Pattern pattern, 101 | {String onMatch(Match match), String onNonMatch(String nonMatch)}) => 102 | KFString(_innerString.splitMapJoin(pattern, 103 | onMatch: onMatch, onNonMatch: onNonMatch)); 104 | KFList get codeUnits => listOf(_innerString.codeUnits); 105 | Runes get runes => _innerString.runes; 106 | KFString toLowerCase() => KFString(_innerString.toLowerCase()); 107 | KFString toUpperCase() => KFString(_innerString.toUpperCase()); 108 | 109 | // kotlin 110 | KFString also(void block(KFString s)) { 111 | block(this); 112 | return this; 113 | } 114 | 115 | R let(R block(KFString s)) => block(this); 116 | KFString takeIf(bool block(KFString s)) => block(this) ? this : null; 117 | KFString takeUnless(bool block(KFString s)) => !block(this) ? this : null; 118 | 119 | KFString substringBefore(Pattern pattern) => 120 | klet(indexOf(pattern), (idx) => idx == -1 ? this : substring(0, idx)); 121 | KFString substringAfter(Pattern pattern) => klet( 122 | indexOf(pattern), 123 | (idx) => idx == -1 124 | ? this 125 | : substring(idx + pattern.toString().length, length)); 126 | KFString substringBeforeLast(Pattern pattern) => 127 | klet(lastIndexOf(pattern), (idx) => idx == -1 ? this : substring(0, idx)); 128 | KFString substringAfterLast(Pattern pattern) => klet( 129 | lastIndexOf(pattern), 130 | (idx) => idx == -1 131 | ? this 132 | : substring(idx + pattern.toString().length, length)); 133 | KFString removeRange(int startIdx, int endIdx) { 134 | if (endIdx < startIdx) 135 | throw Exception( 136 | "End index ($endIdx) is less than start index ($startIdx)."); 137 | return endIdx == startIdx ? this : replaceRange(startIdx, endIdx, ""); 138 | } 139 | 140 | KFString removePrefix(Pattern pattern) => 141 | startsWith(pattern) ? substring(pattern.toString().length, length) : this; 142 | KFString removeSuffix(Pattern pattern) => endsWith(pattern.toString()) 143 | ? substring(0, length - pattern.toString().length) 144 | : this; 145 | KFString removeSurrounding(Pattern pattern) => 146 | removePrefix(pattern).removeSuffix(pattern); 147 | KFString replaceBefore(Pattern pattern, Object replacement) => klet( 148 | indexOf(pattern), 149 | (idx) => idx == -1 ? this : replaceRange(0, idx, replacement)); 150 | KFString replaceAfter(Pattern pattern, Object replacement) => klet( 151 | indexOf(pattern), 152 | (idx) => idx == -1 153 | ? this 154 | : replaceRange(idx + pattern.toString().length, length, replacement)); 155 | KFString replaceAfterLast(Pattern pattern, Object replacement) => klet( 156 | lastIndexOf(pattern), 157 | (idx) => idx == -1 158 | ? this 159 | : replaceRange(idx + pattern.toString().length, length, replacement)); 160 | KFString replaceBeforeLast(Pattern pattern, Object replacement) => klet( 161 | lastIndexOf(pattern), 162 | (idx) => idx == -1 ? this : replaceRange(0, idx, replacement)); 163 | KFList lines() => 164 | listOf(_innerString.split("\n").map((it) => KFString(it)).toList()); 165 | KFString drop(int n) => substring(n); 166 | KFString dropLast(int n) => substring(0, length - n); 167 | KFString filter(bool block(KFString str)) { 168 | var ret = ""; 169 | for (int i = 0; i < length; i++) { 170 | if (block(KFString(_innerString[i]))) ret += _innerString[i]; 171 | } 172 | return KFString(ret); 173 | } 174 | 175 | KFString filterIndexed(bool block(int idx, KFString str)) { 176 | var ret = ""; 177 | for (int i = 0; i < length; i++) { 178 | if (block(i, KFString(_innerString[i]))) ret += _innerString[i]; 179 | } 180 | return KFString(ret); 181 | } 182 | 183 | KFString filterNot(bool block(KFString str)) { 184 | var ret = ""; 185 | for (int i = 0; i < length; i++) { 186 | if (!block(KFString(_innerString[i]))) ret += _innerString[i]; 187 | } 188 | return KFString(ret); 189 | } 190 | 191 | KFString reversed() { 192 | var ret = ""; 193 | for (int i = 0; i < length; i++) { 194 | ret = _innerString[i] + ret; 195 | } 196 | return KFString(ret); 197 | } 198 | 199 | KFList toList() { 200 | var ret = KFList(); 201 | for (int i = 0; i < length; i++) { 202 | ret.add(KFString(_innerString[i])); 203 | } 204 | return ret; 205 | } 206 | 207 | KFList map(T block(KFString s)) { 208 | var ret = KFList(); 209 | for (int i = 0; i < length; i++) { 210 | ret.add(block(KFString(_innerString[i]))); 211 | } 212 | return ret; 213 | } 214 | 215 | KFList mapIndexed(T block(int idx, KFString s)) { 216 | var ret = KFList(); 217 | for (int i = 0; i < length; i++) { 218 | ret.add(block(i, KFString(_innerString[i]))); 219 | } 220 | return ret; 221 | } 222 | 223 | forEach(void action(KFString s)) { 224 | for (int i = 0; i < length; i++) { 225 | action(KFString(_innerString[i])); 226 | } 227 | } 228 | 229 | forEachIndexed(void action(int idx, KFString s)) { 230 | for (int i = 0; i < length; i++) { 231 | action(i, KFString(_innerString[i])); 232 | } 233 | } 234 | 235 | KFString reduce(KFString oper(KFString acc, KFString s)) { 236 | var accumulator = KFString(_innerString[0]); 237 | for (int i = 1; i < length; i++) { 238 | accumulator = oper(accumulator, KFString(_innerString[i])); 239 | } 240 | return accumulator; 241 | } 242 | 243 | KFString reduceIndexed(KFString oper(int idx, KFString acc, KFString s)) { 244 | var accumulator = KFString(_innerString[0]); 245 | for (int i = 1; i < length; i++) { 246 | accumulator = oper(i, accumulator, KFString(_innerString[i])); 247 | } 248 | return accumulator; 249 | } 250 | 251 | int toInt() => int.parse(_innerString); 252 | double toDouble() => double.parse(_innerString); 253 | bool toBool() => _innerString.toLowerCase() == "true"; 254 | 255 | // ktor 256 | // base64encode 257 | KFString base64encode() => stringOf(base64.encode(utf8.encode(_innerString))); 258 | 259 | // base64decode 260 | KFString base64decode() => stringOf(utf8.decode(base64.decode(_innerString))); 261 | 262 | // toByteArray 263 | KFList toIntList() => map((it) => it.codeUnitAt(0)); 264 | 265 | // swift 266 | KFString lastPathPart() => substringAfterLast("/"); 267 | KFString getPathDirectory() => substringBeforeLast("/") 268 | .let((it) => it._innerString == "" ? stringOf("/") : it); 269 | 270 | // rarnu 271 | KFString toJsonEncoded() => 272 | replaceAll("\\", "\\\\").replaceAll("\n", "\\n").replaceAll("\"", "\\\""); 273 | KFString toTitleUpperCase() => substring(0, 1).toUpperCase() + substring(1); 274 | KFString appendPathPart(Object part) { 275 | var ret = _innerString; 276 | if (!ret.endsWith("/")) ret += "/"; 277 | ret += part is String ? part : (part is KFString ? part._innerString : ""); 278 | return KFString(ret); 279 | } 280 | 281 | KFString extension() => 282 | klet(indexOf("."), (idx) => idx == -1 ? "" : substringAfterLast(".")); 283 | KFString replaceTag(String tag, KFString block()) => replaceAll(tag, block()); 284 | KFString skipEmptyLine() => 285 | lines().filterNot((it) => it.trim() == stringOf("")).joinToString("\n"); 286 | KFPair toPair() => 287 | split("=").map((it) => it.trim()).let((it) => KFPair(it[0], it[1])); 288 | save(File f) => f.writeAsStringSync(_innerString); 289 | File asFileWriteText(Object s) { 290 | klet(Directory(substringBeforeLast("/")._innerString), (dfile) { 291 | if (!dfile.existsSync()) dfile.createSync(recursive: true); 292 | }); 293 | return kalso( 294 | File(_innerString), 295 | (ffile) => ffile.writeAsStringSync( 296 | s is String ? s : (s is KFString ? s._innerString : ""))); 297 | } 298 | 299 | KFString asFileReadText() => klet(File(_innerString), 300 | (ffile) => KFString(ffile.existsSync() ? ffile.readAsStringSync() : "")); 301 | asFileMkdirs() => klet(Directory(_innerString), (dir) { 302 | if (!dir.existsSync()) dir.createSync(recursive: true); 303 | }); 304 | File asFile() => File(_innerString); 305 | } 306 | 307 | KFString stringOf(String str) => KFString(str); 308 | -------------------------------------------------------------------------------- /lib/toast_extension.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | toast(BuildContext context, String message, [int duration = 2]) { 4 | var overlayEntry = OverlayEntry( 5 | builder: (context) => Positioned( 6 | top: MediaQuery.of(context).size.height * 0.9, 7 | child: Material( 8 | child: Container( 9 | width: MediaQuery.of(context).size.width, 10 | alignment: Alignment.center, 11 | child: Center( 12 | child: Card( 13 | child: Padding( 14 | padding: EdgeInsets.all(8), 15 | child: Text( 16 | message, 17 | style: TextStyle(color: Colors.white), 18 | ), 19 | ), 20 | color: Colors.grey.shade800, 21 | ), 22 | ), 23 | ), 24 | ))); 25 | Overlay.of(context).insert(overlayEntry); 26 | Future.delayed(Duration(seconds: duration)).then((value) { 27 | overlayEntry.remove(); 28 | }); 29 | } 30 | -------------------------------------------------------------------------------- /pubspec.lock: -------------------------------------------------------------------------------- 1 | # Generated by pub 2 | # See https://dart.dev/tools/pub/glossary#lockfile 3 | packages: 4 | async: 5 | dependency: transitive 6 | description: 7 | name: async 8 | url: "https://pub.dartlang.org" 9 | source: hosted 10 | version: "2.2.0" 11 | boolean_selector: 12 | dependency: transitive 13 | description: 14 | name: boolean_selector 15 | url: "https://pub.dartlang.org" 16 | source: hosted 17 | version: "1.0.5" 18 | charcode: 19 | dependency: transitive 20 | description: 21 | name: charcode 22 | url: "https://pub.dartlang.org" 23 | source: hosted 24 | version: "1.1.2" 25 | collection: 26 | dependency: transitive 27 | description: 28 | name: collection 29 | url: "https://pub.dartlang.org" 30 | source: hosted 31 | version: "1.14.11" 32 | flutter: 33 | dependency: "direct main" 34 | description: flutter 35 | source: sdk 36 | version: "0.0.0" 37 | flutter_test: 38 | dependency: "direct dev" 39 | description: flutter 40 | source: sdk 41 | version: "0.0.0" 42 | matcher: 43 | dependency: transitive 44 | description: 45 | name: matcher 46 | url: "https://pub.dartlang.org" 47 | source: hosted 48 | version: "0.12.5" 49 | meta: 50 | dependency: transitive 51 | description: 52 | name: meta 53 | url: "https://pub.dartlang.org" 54 | source: hosted 55 | version: "1.1.6" 56 | path: 57 | dependency: transitive 58 | description: 59 | name: path 60 | url: "https://pub.dartlang.org" 61 | source: hosted 62 | version: "1.6.2" 63 | pedantic: 64 | dependency: transitive 65 | description: 66 | name: pedantic 67 | url: "https://pub.dartlang.org" 68 | source: hosted 69 | version: "1.7.0" 70 | quiver: 71 | dependency: transitive 72 | description: 73 | name: quiver 74 | url: "https://pub.dartlang.org" 75 | source: hosted 76 | version: "2.0.3" 77 | sky_engine: 78 | dependency: transitive 79 | description: flutter 80 | source: sdk 81 | version: "0.0.99" 82 | source_span: 83 | dependency: transitive 84 | description: 85 | name: source_span 86 | url: "https://pub.dartlang.org" 87 | source: hosted 88 | version: "1.5.5" 89 | stack_trace: 90 | dependency: transitive 91 | description: 92 | name: stack_trace 93 | url: "https://pub.dartlang.org" 94 | source: hosted 95 | version: "1.9.3" 96 | stream_channel: 97 | dependency: transitive 98 | description: 99 | name: stream_channel 100 | url: "https://pub.dartlang.org" 101 | source: hosted 102 | version: "2.0.0" 103 | string_scanner: 104 | dependency: transitive 105 | description: 106 | name: string_scanner 107 | url: "https://pub.dartlang.org" 108 | source: hosted 109 | version: "1.0.4" 110 | term_glyph: 111 | dependency: transitive 112 | description: 113 | name: term_glyph 114 | url: "https://pub.dartlang.org" 115 | source: hosted 116 | version: "1.1.0" 117 | test_api: 118 | dependency: transitive 119 | description: 120 | name: test_api 121 | url: "https://pub.dartlang.org" 122 | source: hosted 123 | version: "0.2.5" 124 | typed_data: 125 | dependency: transitive 126 | description: 127 | name: typed_data 128 | url: "https://pub.dartlang.org" 129 | source: hosted 130 | version: "1.1.6" 131 | vector_math: 132 | dependency: transitive 133 | description: 134 | name: vector_math 135 | url: "https://pub.dartlang.org" 136 | source: hosted 137 | version: "2.0.8" 138 | sdks: 139 | dart: ">=2.2.2 <3.0.0" 140 | -------------------------------------------------------------------------------- /pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: ktflutter 2 | description: A flutter library for lazier programmers. Functions are ported from kotlin. 3 | version: 1.0.2 4 | author: rarnu 5 | homepage: https://github.com/codemonarch/flutter_ktport 6 | 7 | environment: 8 | sdk: ">=2.1.0 <3.0.0" 9 | 10 | dependencies: 11 | flutter: 12 | sdk: flutter 13 | 14 | dev_dependencies: 15 | flutter_test: 16 | sdk: flutter 17 | 18 | flutter: 19 | plugin: 20 | androidPackage: com.rarnu.ktflutter 21 | pluginClass: KtflutterPlugin 22 | -------------------------------------------------------------------------------- /test/ktflutter_http_test.dart: -------------------------------------------------------------------------------- 1 | import 'dart:convert'; 2 | import 'dart:io'; 3 | 4 | import 'package:flutter_test/flutter_test.dart'; 5 | import 'package:ktflutter/http_extension.dart'; 6 | 7 | void main() { 8 | test('http GET', () async { 9 | await testGET(); 10 | }); 11 | 12 | test('http POST', () async { 13 | await testPOST(); 14 | }); 15 | 16 | test('http HEAD', () async { 17 | await testHEAD(); 18 | }); 19 | 20 | test('http PUT', () async { 21 | await testPUT(); 22 | }); 23 | 24 | test('http DELETE', () async { 25 | await testDELETE(); 26 | }); 27 | 28 | test('upload file', () async { 29 | await testUploadFile(); 30 | }); 31 | } 32 | 33 | 34 | Future testGET() async { 35 | return httpGet( 36 | 'https://api.douban.com/v2/movie/top250?start=0&count=1&apikey=0b2bdeda43b5688921839c8ecb20399b', 37 | ).then((HttpResponse response) { 38 | print(response); 39 | }).catchError((error) { 40 | print(error); 41 | }); 42 | } 43 | 44 | Future testPOST() async { 45 | return httpPost( 46 | 'https://api.douban.com/v2/movie/top250?start=0&count=1&apikey=0b2bdeda43b5688921839c8ecb20399b', 47 | body: jsonEncode({ 48 | 'platform': 'app', 49 | 'array': [12345], 50 | }), 51 | ).then((HttpResponse response) { 52 | print(response); 53 | }).catchError((error) { 54 | print(error); 55 | }); 56 | } 57 | 58 | Future testHEAD() async { 59 | return http( 60 | 'https://api.douban.com/v2/movie/top250?start=0&count=1&apikey=0b2bdeda43b5688921839c8ecb20399b', 61 | HttpMethod.HEAD, 62 | ).then((HttpResponse response) { 63 | print(response); 64 | }).catchError((error) { 65 | print(error); 66 | }); 67 | } 68 | 69 | Future testPUT() async { 70 | return http( 71 | 'https://api.douban.com/v2/movie/top250?start=0&count=1&apikey=0b2bdeda43b5688921839c8ecb20399b', 72 | HttpMethod.PUT, 73 | ).then((HttpResponse response) { 74 | print(response); 75 | }).catchError((error) { 76 | print(error); 77 | }); 78 | } 79 | 80 | Future testDELETE() async { 81 | return http( 82 | 'https://api.douban.com/v2/movie/top250?start=0&count=1&apikey=0b2bdeda43b5688921839c8ecb20399b', 83 | HttpMethod.DELETE, 84 | ).then((HttpResponse response) { 85 | print(response); 86 | }).catchError((error) { 87 | print(error); 88 | }); 89 | } 90 | 91 | Future testUploadFile() async { 92 | return http( 93 | 'https://mc.hujiang.com', 94 | HttpMethod.POST, 95 | postParam: { 96 | 'test': 'test1', 97 | }, 98 | fileParam: { 99 | 'f1': '/Users/chenwang/Desktop/1.png', 100 | } 101 | ).then((HttpResponse response) { 102 | print(response); 103 | }).catchError((error) { 104 | print(error); 105 | }); 106 | } -------------------------------------------------------------------------------- /test/ktflutter_test.dart: -------------------------------------------------------------------------------- 1 | import 'dart:convert'; 2 | import 'dart:io'; 3 | import 'dart:math'; 4 | 5 | import 'package:flutter_test/flutter_test.dart'; 6 | import 'package:ktflutter/list_extension.dart'; 7 | import 'package:ktflutter/map_extension.dart'; 8 | import 'package:ktflutter/pair_extension.dart'; 9 | import 'package:ktflutter/regex_extension.dart'; 10 | import 'package:ktflutter/set_extension.dart'; 11 | import 'package:ktflutter/string_extension.dart'; 12 | 13 | void main() { 14 | test('to', () { 15 | 16 | }); 17 | } 18 | --------------------------------------------------------------------------------