From 301ec2dc508e08fe7a484c206c42abd3a6f0df99 Mon Sep 17 00:00:00 2001 From: Bogdan Userman Kikacheishvili Date: Fri, 10 Feb 2023 15:21:38 +0200 Subject: [PATCH] Project added. --- .gitignore | 248 +++++++ .metadata | 10 + CHANGELOG.md | 3 + README.md | 34 + generator.dart | 120 +++ lib/tuples.dart | 763 +++++++++++++++++++ lib/type_saving_wait.dart | 1210 +++++++++++++++++++++++++++++++ pubspec.lock | 154 ++++ pubspec.yaml | 54 ++ test/type_saving_wait_test.dart | 3 + type_saving_wait.iml | 19 + 11 files changed, 2618 insertions(+) create mode 100644 .gitignore create mode 100644 .metadata create mode 100644 CHANGELOG.md create mode 100644 README.md create mode 100644 generator.dart create mode 100644 lib/tuples.dart create mode 100644 lib/type_saving_wait.dart create mode 100644 pubspec.lock create mode 100644 pubspec.yaml create mode 100644 test/type_saving_wait_test.dart create mode 100644 type_saving_wait.iml diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..77da29d --- /dev/null +++ b/.gitignore @@ -0,0 +1,248 @@ +# Created by https://www.toptal.com/developers/gitignore/api/flutter,visualstudiocode,androidstudio,dart +# Edit at https://www.toptal.com/developers/gitignore?templates=flutter,visualstudiocode,androidstudio,dart + +### Dart ### +# See https://www.dartlang.org/guides/libraries/private-files + +# Files and directories created by pub +.dart_tool/ +.packages +build/ +# If you're building an application, you may want to check-in your pubspec.lock +# pubspec.lock + +# Directory created by dartdoc +# If you don't generate documentation locally you can remove this line. +doc/api/ + +# dotenv environment variables file +.env* + +# Avoid committing generated Javascript files: +*.dart.js +*.info.json # Produced by the --dump-info flag. +*.js # When generated by dart2js. Don't specify *.js if your + # project includes source files written in JavaScript. +*.js_ +*.js.deps +*.js.map + +.flutter-plugins +.flutter-plugins-dependencies + +### Dart Patch ### +# dotenv environment variables file +.env + +### Flutter ### +# Flutter/Dart/Pub related +**/doc/api/ +.fvm/flutter_sdk +.pub-cache/ +.pub/ +coverage/ +lib/generated_plugin_registrant.dart +# For library packages, don’t commit the pubspec.lock file. +# Regenerating the pubspec.lock file lets you test your package against the latest compatible versions of its dependencies. +# See https://dart.dev/guides/libraries/private-files#pubspeclock +#pubspec.lock + +# Android related +**/android/**/gradle-wrapper.jar +**/android/.gradle +**/android/captures/ +**/android/gradlew +**/android/gradlew.bat +**/android/key.properties +**/android/local.properties +**/android/**/GeneratedPluginRegistrant.java + +# iOS/XCode related +**/ios/**/*.mode1v3 +**/ios/**/*.mode2v3 +**/ios/**/*.moved-aside +**/ios/**/*.pbxuser +**/ios/**/*.perspectivev3 +**/ios/**/*sync/ +**/ios/**/.sconsign.dblite +**/ios/**/.tags* +**/ios/**/.vagrant/ +**/ios/**/DerivedData/ +**/ios/**/Icon? +**/ios/**/Pods/ +**/ios/**/.symlinks/ +**/ios/**/profile +**/ios/**/xcuserdata +**/ios/.generated/ +**/ios/Flutter/.last_build_id +**/ios/Flutter/App.framework +**/ios/Flutter/Flutter.framework +**/ios/Flutter/Flutter.podspec +**/ios/Flutter/Generated.xcconfig +**/ios/Flutter/app.flx +**/ios/Flutter/app.zip +**/ios/Flutter/flutter_assets/ +**/ios/Flutter/flutter_export_environment.sh +**/ios/ServiceDefinitions.json +**/ios/Runner/GeneratedPluginRegistrant.* + +# Exceptions to above rules. +!**/ios/**/default.mode1v3 +!**/ios/**/default.mode2v3 +!**/ios/**/default.pbxuser +!**/ios/**/default.perspectivev3 +!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages + +### VisualStudioCode ### +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +!.vscode/*.code-snippets + +# Local History for Visual Studio Code +.history/ + +# Built Visual Studio Code Extensions +*.vsix + +### VisualStudioCode Patch ### +# Ignore all local history of files +.history +.ionide + +### AndroidStudio ### +# Covers files to be ignored for android development using Android Studio. + +# Built application files +*.apk +*.ap_ +*.aab + +# Files for the ART/Dalvik VM +*.dex + +# Java class files +*.class + +# Generated files +bin/ +gen/ +out/ + +# Gradle files +.gradle +.gradle/ + +# Signing files +.signing/ + +# Local configuration file (sdk path, etc) +local.properties + +# Proguard folder generated by Eclipse +proguard/ + +# Log Files +*.log + +# Android Studio +/*/build/ +/*/local.properties +/*/out +/*/*/build +/*/*/production +captures/ +.navigation/ +*.ipr +*~ +*.swp + +# Keystore files +*.jks +*.keystore + +# Google Services (e.g. APIs or Firebase) +# google-services.json + +# Android Patch +gen-external-apklibs + +# External native build folder generated in Android Studio 2.2 and later +.externalNativeBuild + +# NDK +obj/ + +# IntelliJ IDEA +*.iml +!type_saving_wait.iml +*.iws +/out/ + + +# User-specific configurations +.idea/caches/ +.idea/libraries/ +.idea/shelf/ +.idea/workspace.xml +.idea/tasks.xml +.idea/.name +.idea/compiler.xml +.idea/copyright/profiles_settings.xml +.idea/encodings.xml +.idea/misc.xml +.idea/modules.xml +.idea/scopes/scope_settings.xml +.idea/dictionaries +.idea/vcs.xml +.idea/jsLibraryMappings.xml +.idea/datasources.xml +.idea/dataSources.ids +.idea/sqlDataSources.xml +.idea/dynamic.xml +.idea/uiDesigner.xml +.idea/assetWizardSettings.xml +.idea/gradle.xml +.idea/jarRepositories.xml +.idea/navEditor.xml + +# Legacy Eclipse project files +.classpath +.project +.cproject +.settings/ + +# Mobile Tools for Java (J2ME) +.mtj.tmp/ + +# Package Files # +*.war +*.ear + +# virtual machine crash logs (Reference: http://www.java.com/en/download/help/error_hotspot.xml) +hs_err_pid* + +## Plugin-specific files: + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Mongo Explorer plugin +.idea/mongoSettings.xml + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +### AndroidStudio Patch ### + +!/gradle/wrapper/gradle-wrapper.jar + +# End of https://www.toptal.com/developers/gitignore/api/flutter,visualstudiocode,androidstudio,dart \ No newline at end of file diff --git a/.metadata b/.metadata new file mode 100644 index 0000000..6c08927 --- /dev/null +++ b/.metadata @@ -0,0 +1,10 @@ +# This file tracks properties of this Flutter project. +# Used by Flutter tool to assess capabilities and perform upgrades etc. +# +# This file should be version controlled and should not be manually edited. + +version: + revision: e3c29ec00c9c825c891d75054c63fcc46454dca1 + channel: stable + +project_type: package diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..943420c --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,3 @@ +## 0.0.1 + +- Generation of Tuples and Futures implemented. diff --git a/README.md b/README.md new file mode 100644 index 0000000..0aeb1da --- /dev/null +++ b/README.md @@ -0,0 +1,34 @@ + + +# Type saving wait + +It is not really convenient to use Future.wait, cause it's leading to type erasing, so this lib created to help you save types while use Future.wait feature. This lib supports up to 24 arguments for saving. So if you wondering how to save type of arguments in Future.wait, this is for you! + +## Usage + +To use this plugin, add `type_saving_wait` as a [dependency in your pubspec.yaml file](https://flutter.dev/docs/development/platform-integration/platform-channels). + +### Examples +Here are small example that show you how to use this library. + +#### Creation of native page route +```dart +FutureSaving.wait2( + Future.value(3.14), + Future.value('Awesomness'), + ).then((value) { + double a = value.a; + String b = value.b; + }); +``` \ No newline at end of file diff --git a/generator.dart b/generator.dart new file mode 100644 index 0000000..b9971cb --- /dev/null +++ b/generator.dart @@ -0,0 +1,120 @@ +import 'dart:io'; + +void main() async { + const alphabet = 'ABCDEFGHJKLMNPQRSTUVWXYZ'; + const length = alphabet.length; + + generateTuples(alphabet, length); + generateFutures(alphabet, length); +} + +void generateFutures(String alphabet, int length) { + File futures = File('lib/type_saving_wait.dart'); + String result = 'library type_saving_wait;\n\n'; + result += 'import \'package:type_saving_wait/tuples.dart\';\n\n'; + result += + '///Currently is not possible to create static function in Extension\n'; + result += + '///so now we need to use FutureSaving.wait, instead of Future.wait\n'; + result += 'extension FutureSaving on Future {\n\n'; + + for (var i = 2; i <= length; i++) { + final letters = alphabet.substring(0, i); + final splitted = letters.split(''); + + result += + '///Function for save $i arguments types\nstatic Future>'); + + result += ' wait$i<\$0'; + + for (var element in splitted) { + result = result.replaceAll('\$0', element); + + result += ', \$0'; + } + + result = result.replaceAll(', \$0', '>'); + + result += '(\$0'; + + for (var element in splitted) { + result = + result.replaceAll('\$0', 'Future<$element> ${element.toLowerCase()}'); + + result += ', \$0'; + } + + result = result.replaceAll(', \$0', ',) {\n'); + + result += 'return Future.wait([\$0'; + + for (var element in splitted) { + result = result.replaceAll('\$0', element.toLowerCase()); + + result += ', \$0'; + } + + result = result.replaceAll(', \$0', ',],)\n'); + + result += '.then((value) => FutureResult$i(\$0'; + var j = 0; + for (var element in splitted) { + result = result.replaceAll('\$0', 'value[${j++}] as $element'); + result += ', \$0'; + } + + result = result.replaceAll(', \$0', ',),);\n'); + result += '}\n'; + } + result += '}'; + futures.writeAsStringSync(result); +} + +void generateTuples(String alphabet, int length) { + File tuples = File('lib/tuples.dart'); //load the json file + tuples.writeAsStringSync(''); + + for (var i = 2; i <= length; i++) { + final letters = alphabet.substring(0, i); + final splitted = letters.split(''); + String result = + '///Class for handle $i arguments inside\nclass FutureResult$i<\$0'; + + for (var element in splitted) { + result = result.replaceAll('\$0', element); + + result += ', \$0'; + } + + result = result.replaceAll(', \$0', '> { \n\$0'); + + for (var element in splitted) { + result = result.replaceAll( + '\$0', 'final $element ${element.toLowerCase()};\n'); + + result += '\$0'; + } + + result = result.replaceAll('\$0', '\n'); + + result += 'FutureResult$i(\$0'; + + for (var element in splitted) { + result = result.replaceAll('\$0', 'this.${element.toLowerCase()}, '); + + result += '\$0'; + } + + result = result.replaceAll(', \$0', ',);\n}\n'); + + tuples.writeAsStringSync(result, mode: FileMode.append); + } +} diff --git a/lib/tuples.dart b/lib/tuples.dart new file mode 100644 index 0000000..c8f9c2e --- /dev/null +++ b/lib/tuples.dart @@ -0,0 +1,763 @@ +///Class for handle 2 arguments inside +class FutureResult2 { + final A a; + final B b; + + FutureResult2( + this.a, + this.b, + ); +} + +///Class for handle 3 arguments inside +class FutureResult3 { + final A a; + final B b; + final C c; + + FutureResult3( + this.a, + this.b, + this.c, + ); +} + +///Class for handle 4 arguments inside +class FutureResult4 { + final A a; + final B b; + final C c; + final D d; + + FutureResult4( + this.a, + this.b, + this.c, + this.d, + ); +} + +///Class for handle 5 arguments inside +class FutureResult5 { + final A a; + final B b; + final C c; + final D d; + final E e; + + FutureResult5( + this.a, + this.b, + this.c, + this.d, + this.e, + ); +} + +///Class for handle 6 arguments inside +class FutureResult6 { + final A a; + final B b; + final C c; + final D d; + final E e; + final F f; + + FutureResult6( + this.a, + this.b, + this.c, + this.d, + this.e, + this.f, + ); +} + +///Class for handle 7 arguments inside +class FutureResult7 { + final A a; + final B b; + final C c; + final D d; + final E e; + final F f; + final G g; + + FutureResult7( + this.a, + this.b, + this.c, + this.d, + this.e, + this.f, + this.g, + ); +} + +///Class for handle 8 arguments inside +class FutureResult8 { + final A a; + final B b; + final C c; + final D d; + final E e; + final F f; + final G g; + final H h; + + FutureResult8( + this.a, + this.b, + this.c, + this.d, + this.e, + this.f, + this.g, + this.h, + ); +} + +///Class for handle 9 arguments inside +class FutureResult9 { + final A a; + final B b; + final C c; + final D d; + final E e; + final F f; + final G g; + final H h; + final J j; + + FutureResult9( + this.a, + this.b, + this.c, + this.d, + this.e, + this.f, + this.g, + this.h, + this.j, + ); +} + +///Class for handle 10 arguments inside +class FutureResult10 { + final A a; + final B b; + final C c; + final D d; + final E e; + final F f; + final G g; + final H h; + final J j; + final K k; + + FutureResult10( + this.a, + this.b, + this.c, + this.d, + this.e, + this.f, + this.g, + this.h, + this.j, + this.k, + ); +} + +///Class for handle 11 arguments inside +class FutureResult11 { + final A a; + final B b; + final C c; + final D d; + final E e; + final F f; + final G g; + final H h; + final J j; + final K k; + final L l; + + FutureResult11( + this.a, + this.b, + this.c, + this.d, + this.e, + this.f, + this.g, + this.h, + this.j, + this.k, + this.l, + ); +} + +///Class for handle 12 arguments inside +class FutureResult12 { + final A a; + final B b; + final C c; + final D d; + final E e; + final F f; + final G g; + final H h; + final J j; + final K k; + final L l; + final M m; + + FutureResult12( + this.a, + this.b, + this.c, + this.d, + this.e, + this.f, + this.g, + this.h, + this.j, + this.k, + this.l, + this.m, + ); +} + +///Class for handle 13 arguments inside +class FutureResult13 { + final A a; + final B b; + final C c; + final D d; + final E e; + final F f; + final G g; + final H h; + final J j; + final K k; + final L l; + final M m; + final N n; + + FutureResult13( + this.a, + this.b, + this.c, + this.d, + this.e, + this.f, + this.g, + this.h, + this.j, + this.k, + this.l, + this.m, + this.n, + ); +} + +///Class for handle 14 arguments inside +class FutureResult14 { + final A a; + final B b; + final C c; + final D d; + final E e; + final F f; + final G g; + final H h; + final J j; + final K k; + final L l; + final M m; + final N n; + final P p; + + FutureResult14( + this.a, + this.b, + this.c, + this.d, + this.e, + this.f, + this.g, + this.h, + this.j, + this.k, + this.l, + this.m, + this.n, + this.p, + ); +} + +///Class for handle 15 arguments inside +class FutureResult15 { + final A a; + final B b; + final C c; + final D d; + final E e; + final F f; + final G g; + final H h; + final J j; + final K k; + final L l; + final M m; + final N n; + final P p; + final Q q; + + FutureResult15( + this.a, + this.b, + this.c, + this.d, + this.e, + this.f, + this.g, + this.h, + this.j, + this.k, + this.l, + this.m, + this.n, + this.p, + this.q, + ); +} + +///Class for handle 16 arguments inside +class FutureResult16 { + final A a; + final B b; + final C c; + final D d; + final E e; + final F f; + final G g; + final H h; + final J j; + final K k; + final L l; + final M m; + final N n; + final P p; + final Q q; + final R r; + + FutureResult16( + this.a, + this.b, + this.c, + this.d, + this.e, + this.f, + this.g, + this.h, + this.j, + this.k, + this.l, + this.m, + this.n, + this.p, + this.q, + this.r, + ); +} + +///Class for handle 17 arguments inside +class FutureResult17 { + final A a; + final B b; + final C c; + final D d; + final E e; + final F f; + final G g; + final H h; + final J j; + final K k; + final L l; + final M m; + final N n; + final P p; + final Q q; + final R r; + final S s; + + FutureResult17( + this.a, + this.b, + this.c, + this.d, + this.e, + this.f, + this.g, + this.h, + this.j, + this.k, + this.l, + this.m, + this.n, + this.p, + this.q, + this.r, + this.s, + ); +} + +///Class for handle 18 arguments inside +class FutureResult18 { + final A a; + final B b; + final C c; + final D d; + final E e; + final F f; + final G g; + final H h; + final J j; + final K k; + final L l; + final M m; + final N n; + final P p; + final Q q; + final R r; + final S s; + final T t; + + FutureResult18( + this.a, + this.b, + this.c, + this.d, + this.e, + this.f, + this.g, + this.h, + this.j, + this.k, + this.l, + this.m, + this.n, + this.p, + this.q, + this.r, + this.s, + this.t, + ); +} + +///Class for handle 19 arguments inside +class FutureResult19 { + final A a; + final B b; + final C c; + final D d; + final E e; + final F f; + final G g; + final H h; + final J j; + final K k; + final L l; + final M m; + final N n; + final P p; + final Q q; + final R r; + final S s; + final T t; + final U u; + + FutureResult19( + this.a, + this.b, + this.c, + this.d, + this.e, + this.f, + this.g, + this.h, + this.j, + this.k, + this.l, + this.m, + this.n, + this.p, + this.q, + this.r, + this.s, + this.t, + this.u, + ); +} + +///Class for handle 20 arguments inside +class FutureResult20 { + final A a; + final B b; + final C c; + final D d; + final E e; + final F f; + final G g; + final H h; + final J j; + final K k; + final L l; + final M m; + final N n; + final P p; + final Q q; + final R r; + final S s; + final T t; + final U u; + final V v; + + FutureResult20( + this.a, + this.b, + this.c, + this.d, + this.e, + this.f, + this.g, + this.h, + this.j, + this.k, + this.l, + this.m, + this.n, + this.p, + this.q, + this.r, + this.s, + this.t, + this.u, + this.v, + ); +} + +///Class for handle 21 arguments inside +class FutureResult21 { + final A a; + final B b; + final C c; + final D d; + final E e; + final F f; + final G g; + final H h; + final J j; + final K k; + final L l; + final M m; + final N n; + final P p; + final Q q; + final R r; + final S s; + final T t; + final U u; + final V v; + final W w; + + FutureResult21( + this.a, + this.b, + this.c, + this.d, + this.e, + this.f, + this.g, + this.h, + this.j, + this.k, + this.l, + this.m, + this.n, + this.p, + this.q, + this.r, + this.s, + this.t, + this.u, + this.v, + this.w, + ); +} + +///Class for handle 22 arguments inside +class FutureResult22 { + final A a; + final B b; + final C c; + final D d; + final E e; + final F f; + final G g; + final H h; + final J j; + final K k; + final L l; + final M m; + final N n; + final P p; + final Q q; + final R r; + final S s; + final T t; + final U u; + final V v; + final W w; + final X x; + + FutureResult22( + this.a, + this.b, + this.c, + this.d, + this.e, + this.f, + this.g, + this.h, + this.j, + this.k, + this.l, + this.m, + this.n, + this.p, + this.q, + this.r, + this.s, + this.t, + this.u, + this.v, + this.w, + this.x, + ); +} + +///Class for handle 23 arguments inside +class FutureResult23 { + final A a; + final B b; + final C c; + final D d; + final E e; + final F f; + final G g; + final H h; + final J j; + final K k; + final L l; + final M m; + final N n; + final P p; + final Q q; + final R r; + final S s; + final T t; + final U u; + final V v; + final W w; + final X x; + final Y y; + + FutureResult23( + this.a, + this.b, + this.c, + this.d, + this.e, + this.f, + this.g, + this.h, + this.j, + this.k, + this.l, + this.m, + this.n, + this.p, + this.q, + this.r, + this.s, + this.t, + this.u, + this.v, + this.w, + this.x, + this.y, + ); +} + +///Class for handle 24 arguments inside +class FutureResult24 { + final A a; + final B b; + final C c; + final D d; + final E e; + final F f; + final G g; + final H h; + final J j; + final K k; + final L l; + final M m; + final N n; + final P p; + final Q q; + final R r; + final S s; + final T t; + final U u; + final V v; + final W w; + final X x; + final Y y; + final Z z; + + FutureResult24( + this.a, + this.b, + this.c, + this.d, + this.e, + this.f, + this.g, + this.h, + this.j, + this.k, + this.l, + this.m, + this.n, + this.p, + this.q, + this.r, + this.s, + this.t, + this.u, + this.v, + this.w, + this.x, + this.y, + this.z, + ); +} diff --git a/lib/type_saving_wait.dart b/lib/type_saving_wait.dart new file mode 100644 index 0000000..f850beb --- /dev/null +++ b/lib/type_saving_wait.dart @@ -0,0 +1,1210 @@ +library type_saving_wait; + +import 'package:type_saving_wait/tuples.dart'; + +///Currently is not possible to create static function in Extension +///so now we need to use FutureSaving.wait, instead of Future.wait +extension FutureSaving on Future { + ///Function for save 2 arguments types + static Future> wait2( + Future a, + Future b, + ) { + return Future.wait( + [ + a, + b, + ], + ).then( + (value) => FutureResult2( + value[0] as A, + value[1] as B, + ), + ); + } + + ///Function for save 3 arguments types + static Future> wait3( + Future a, + Future b, + Future c, + ) { + return Future.wait( + [ + a, + b, + c, + ], + ).then( + (value) => FutureResult3( + value[0] as A, + value[1] as B, + value[2] as C, + ), + ); + } + + ///Function for save 4 arguments types + static Future> wait4( + Future a, + Future b, + Future c, + Future d, + ) { + return Future.wait( + [ + a, + b, + c, + d, + ], + ).then( + (value) => FutureResult4( + value[0] as A, + value[1] as B, + value[2] as C, + value[3] as D, + ), + ); + } + + ///Function for save 5 arguments types + static Future> wait5( + Future a, + Future b, + Future c, + Future d, + Future e, + ) { + return Future.wait( + [ + a, + b, + c, + d, + e, + ], + ).then( + (value) => FutureResult5( + value[0] as A, + value[1] as B, + value[2] as C, + value[3] as D, + value[4] as E, + ), + ); + } + + ///Function for save 6 arguments types + static Future> wait6( + Future a, + Future b, + Future c, + Future d, + Future e, + Future f, + ) { + return Future.wait( + [ + a, + b, + c, + d, + e, + f, + ], + ).then( + (value) => FutureResult6( + value[0] as A, + value[1] as B, + value[2] as C, + value[3] as D, + value[4] as E, + value[5] as F, + ), + ); + } + + ///Function for save 7 arguments types + static Future> wait7( + Future a, + Future b, + Future c, + Future d, + Future e, + Future f, + Future g, + ) { + return Future.wait( + [ + a, + b, + c, + d, + e, + f, + g, + ], + ).then( + (value) => FutureResult7( + value[0] as A, + value[1] as B, + value[2] as C, + value[3] as D, + value[4] as E, + value[5] as F, + value[6] as G, + ), + ); + } + + ///Function for save 8 arguments types + static Future> + wait8( + Future a, + Future b, + Future c, + Future d, + Future e, + Future f, + Future g, + Future h, + ) { + return Future.wait( + [ + a, + b, + c, + d, + e, + f, + g, + h, + ], + ).then( + (value) => FutureResult8( + value[0] as A, + value[1] as B, + value[2] as C, + value[3] as D, + value[4] as E, + value[5] as F, + value[6] as G, + value[7] as H, + ), + ); + } + + ///Function for save 9 arguments types + static Future> + wait9( + Future a, + Future b, + Future c, + Future d, + Future e, + Future f, + Future g, + Future h, + Future j, + ) { + return Future.wait( + [ + a, + b, + c, + d, + e, + f, + g, + h, + j, + ], + ).then( + (value) => FutureResult9( + value[0] as A, + value[1] as B, + value[2] as C, + value[3] as D, + value[4] as E, + value[5] as F, + value[6] as G, + value[7] as H, + value[8] as J, + ), + ); + } + + ///Function for save 10 arguments types + static Future> + wait10( + Future a, + Future b, + Future c, + Future d, + Future e, + Future f, + Future g, + Future h, + Future j, + Future k, + ) { + return Future.wait( + [ + a, + b, + c, + d, + e, + f, + g, + h, + j, + k, + ], + ).then( + (value) => FutureResult10( + value[0] as A, + value[1] as B, + value[2] as C, + value[3] as D, + value[4] as E, + value[5] as F, + value[6] as G, + value[7] as H, + value[8] as J, + value[9] as K, + ), + ); + } + + ///Function for save 11 arguments types + static Future> + wait11( + Future a, + Future b, + Future c, + Future d, + Future e, + Future f, + Future g, + Future h, + Future j, + Future k, + Future l, + ) { + return Future.wait( + [ + a, + b, + c, + d, + e, + f, + g, + h, + j, + k, + l, + ], + ).then( + (value) => FutureResult11( + value[0] as A, + value[1] as B, + value[2] as C, + value[3] as D, + value[4] as E, + value[5] as F, + value[6] as G, + value[7] as H, + value[8] as J, + value[9] as K, + value[10] as L, + ), + ); + } + + ///Function for save 12 arguments types + static Future> + wait12( + Future a, + Future b, + Future c, + Future d, + Future e, + Future f, + Future g, + Future h, + Future j, + Future k, + Future l, + Future m, + ) { + return Future.wait( + [ + a, + b, + c, + d, + e, + f, + g, + h, + j, + k, + l, + m, + ], + ).then( + (value) => FutureResult12( + value[0] as A, + value[1] as B, + value[2] as C, + value[3] as D, + value[4] as E, + value[5] as F, + value[6] as G, + value[7] as H, + value[8] as J, + value[9] as K, + value[10] as L, + value[11] as M, + ), + ); + } + + ///Function for save 13 arguments types + static Future> + wait13( + Future a, + Future b, + Future c, + Future d, + Future e, + Future f, + Future g, + Future h, + Future j, + Future k, + Future l, + Future m, + Future n, + ) { + return Future.wait( + [ + a, + b, + c, + d, + e, + f, + g, + h, + j, + k, + l, + m, + n, + ], + ).then( + (value) => FutureResult13( + value[0] as A, + value[1] as B, + value[2] as C, + value[3] as D, + value[4] as E, + value[5] as F, + value[6] as G, + value[7] as H, + value[8] as J, + value[9] as K, + value[10] as L, + value[11] as M, + value[12] as N, + ), + ); + } + + ///Function for save 14 arguments types + static Future> + wait14( + Future a, + Future b, + Future c, + Future d, + Future e, + Future f, + Future g, + Future h, + Future j, + Future k, + Future l, + Future m, + Future n, + Future

p, + Future q, + ) { + return Future.wait( + [ + a, + b, + c, + d, + e, + f, + g, + h, + j, + k, + l, + m, + n, + p, + q, + ], + ).then( + (value) => FutureResult15( + value[0] as A, + value[1] as B, + value[2] as C, + value[3] as D, + value[4] as E, + value[5] as F, + value[6] as G, + value[7] as H, + value[8] as J, + value[9] as K, + value[10] as L, + value[11] as M, + value[12] as N, + value[13] as P, + value[14] as Q, + ), + ); + } + + ///Function for save 16 arguments types + static Future> + wait16( + Future a, + Future b, + Future c, + Future d, + Future e, + Future f, + Future g, + Future h, + Future j, + Future k, + Future l, + Future m, + Future n, + Future

p, + Future q, + Future r, + ) { + return Future.wait( + [ + a, + b, + c, + d, + e, + f, + g, + h, + j, + k, + l, + m, + n, + p, + q, + r, + ], + ).then( + (value) => FutureResult16( + value[0] as A, + value[1] as B, + value[2] as C, + value[3] as D, + value[4] as E, + value[5] as F, + value[6] as G, + value[7] as H, + value[8] as J, + value[9] as K, + value[10] as L, + value[11] as M, + value[12] as N, + value[13] as P, + value[14] as Q, + value[15] as R, + ), + ); + } + + ///Function for save 17 arguments types + static Future< + FutureResult17> + wait17( + Future a, + Future b, + Future c, + Future d, + Future e, + Future f, + Future g, + Future h, + Future j, + Future k, + Future l, + Future m, + Future n, + Future

p, + Future q, + Future r, + Future s, + ) { + return Future.wait( + [ + a, + b, + c, + d, + e, + f, + g, + h, + j, + k, + l, + m, + n, + p, + q, + r, + s, + ], + ).then( + (value) => FutureResult17( + value[0] as A, + value[1] as B, + value[2] as C, + value[3] as D, + value[4] as E, + value[5] as F, + value[6] as G, + value[7] as H, + value[8] as J, + value[9] as K, + value[10] as L, + value[11] as M, + value[12] as N, + value[13] as P, + value[14] as Q, + value[15] as R, + value[16] as S, + ), + ); + } + + ///Function for save 18 arguments types + static Future< + FutureResult18> + wait18( + Future a, + Future b, + Future c, + Future d, + Future e, + Future f, + Future g, + Future h, + Future j, + Future k, + Future l, + Future m, + Future n, + Future

p, + Future q, + Future r, + Future s, + Future t, + ) { + return Future.wait( + [ + a, + b, + c, + d, + e, + f, + g, + h, + j, + k, + l, + m, + n, + p, + q, + r, + s, + t, + ], + ).then( + (value) => FutureResult18( + value[0] as A, + value[1] as B, + value[2] as C, + value[3] as D, + value[4] as E, + value[5] as F, + value[6] as G, + value[7] as H, + value[8] as J, + value[9] as K, + value[10] as L, + value[11] as M, + value[12] as N, + value[13] as P, + value[14] as Q, + value[15] as R, + value[16] as S, + value[17] as T, + ), + ); + } + + ///Function for save 19 arguments types + static Future< + FutureResult19> wait19( + Future a, + Future b, + Future c, + Future d, + Future e, + Future f, + Future g, + Future h, + Future j, + Future k, + Future l, + Future m, + Future n, + Future

p, + Future q, + Future r, + Future s, + Future t, + Future u, + ) { + return Future.wait( + [ + a, + b, + c, + d, + e, + f, + g, + h, + j, + k, + l, + m, + n, + p, + q, + r, + s, + t, + u, + ], + ).then( + (value) => FutureResult19( + value[0] as A, + value[1] as B, + value[2] as C, + value[3] as D, + value[4] as E, + value[5] as F, + value[6] as G, + value[7] as H, + value[8] as J, + value[9] as K, + value[10] as L, + value[11] as M, + value[12] as N, + value[13] as P, + value[14] as Q, + value[15] as R, + value[16] as S, + value[17] as T, + value[18] as U, + ), + ); + } + + ///Function for save 20 arguments types + static Future< + FutureResult20> + wait20( + Future a, + Future b, + Future c, + Future d, + Future e, + Future f, + Future g, + Future h, + Future j, + Future k, + Future l, + Future m, + Future n, + Future

p, + Future q, + Future r, + Future s, + Future t, + Future u, + Future v, + ) { + return Future.wait( + [ + a, + b, + c, + d, + e, + f, + g, + h, + j, + k, + l, + m, + n, + p, + q, + r, + s, + t, + u, + v, + ], + ).then( + (value) => FutureResult20( + value[0] as A, + value[1] as B, + value[2] as C, + value[3] as D, + value[4] as E, + value[5] as F, + value[6] as G, + value[7] as H, + value[8] as J, + value[9] as K, + value[10] as L, + value[11] as M, + value[12] as N, + value[13] as P, + value[14] as Q, + value[15] as R, + value[16] as S, + value[17] as T, + value[18] as U, + value[19] as V, + ), + ); + } + + ///Function for save 21 arguments types + static Future< + FutureResult21> + wait21( + Future a, + Future b, + Future c, + Future d, + Future e, + Future f, + Future g, + Future h, + Future j, + Future k, + Future l, + Future m, + Future n, + Future

p, + Future q, + Future r, + Future s, + Future t, + Future u, + Future v, + Future w, + ) { + return Future.wait( + [ + a, + b, + c, + d, + e, + f, + g, + h, + j, + k, + l, + m, + n, + p, + q, + r, + s, + t, + u, + v, + w, + ], + ).then( + (value) => FutureResult21( + value[0] as A, + value[1] as B, + value[2] as C, + value[3] as D, + value[4] as E, + value[5] as F, + value[6] as G, + value[7] as H, + value[8] as J, + value[9] as K, + value[10] as L, + value[11] as M, + value[12] as N, + value[13] as P, + value[14] as Q, + value[15] as R, + value[16] as S, + value[17] as T, + value[18] as U, + value[19] as V, + value[20] as W, + ), + ); + } + + ///Function for save 22 arguments types + static Future< + FutureResult22> + wait22( + Future a, + Future b, + Future c, + Future d, + Future e, + Future f, + Future g, + Future h, + Future j, + Future k, + Future l, + Future m, + Future n, + Future

p, + Future q, + Future r, + Future s, + Future t, + Future u, + Future v, + Future w, + Future x, + ) { + return Future.wait( + [ + a, + b, + c, + d, + e, + f, + g, + h, + j, + k, + l, + m, + n, + p, + q, + r, + s, + t, + u, + v, + w, + x, + ], + ).then( + (value) => FutureResult22( + value[0] as A, + value[1] as B, + value[2] as C, + value[3] as D, + value[4] as E, + value[5] as F, + value[6] as G, + value[7] as H, + value[8] as J, + value[9] as K, + value[10] as L, + value[11] as M, + value[12] as N, + value[13] as P, + value[14] as Q, + value[15] as R, + value[16] as S, + value[17] as T, + value[18] as U, + value[19] as V, + value[20] as W, + value[21] as X, + ), + ); + } + + ///Function for save 23 arguments types + static Future< + FutureResult23> wait23( + Future a, + Future b, + Future c, + Future d, + Future e, + Future f, + Future g, + Future h, + Future j, + Future k, + Future l, + Future m, + Future n, + Future

p, + Future q, + Future r, + Future s, + Future t, + Future u, + Future v, + Future w, + Future x, + Future y, + ) { + return Future.wait( + [ + a, + b, + c, + d, + e, + f, + g, + h, + j, + k, + l, + m, + n, + p, + q, + r, + s, + t, + u, + v, + w, + x, + y, + ], + ).then( + (value) => FutureResult23( + value[0] as A, + value[1] as B, + value[2] as C, + value[3] as D, + value[4] as E, + value[5] as F, + value[6] as G, + value[7] as H, + value[8] as J, + value[9] as K, + value[10] as L, + value[11] as M, + value[12] as N, + value[13] as P, + value[14] as Q, + value[15] as R, + value[16] as S, + value[17] as T, + value[18] as U, + value[19] as V, + value[20] as W, + value[21] as X, + value[22] as Y, + ), + ); + } + + ///Function for save 24 arguments types + static Future< + FutureResult24> wait24( + Future a, + Future b, + Future c, + Future d, + Future e, + Future f, + Future g, + Future h, + Future j, + Future k, + Future l, + Future m, + Future n, + Future

p, + Future q, + Future r, + Future s, + Future t, + Future u, + Future v, + Future w, + Future x, + Future y, + Future z, + ) { + return Future.wait( + [ + a, + b, + c, + d, + e, + f, + g, + h, + j, + k, + l, + m, + n, + p, + q, + r, + s, + t, + u, + v, + w, + x, + y, + z, + ], + ).then( + (value) => FutureResult24( + value[0] as A, + value[1] as B, + value[2] as C, + value[3] as D, + value[4] as E, + value[5] as F, + value[6] as G, + value[7] as H, + value[8] as J, + value[9] as K, + value[10] as L, + value[11] as M, + value[12] as N, + value[13] as P, + value[14] as Q, + value[15] as R, + value[16] as S, + value[17] as T, + value[18] as U, + value[19] as V, + value[20] as W, + value[21] as X, + value[22] as Y, + value[23] as Z, + ), + ); + } +} diff --git a/pubspec.lock b/pubspec.lock new file mode 100644 index 0000000..6fb7bda --- /dev/null +++ b/pubspec.lock @@ -0,0 +1,154 @@ +# Generated by pub +# See https://dart.dev/tools/pub/glossary#lockfile +packages: + async: + dependency: transitive + description: + name: async + url: "https://pub.dartlang.org" + source: hosted + version: "2.9.0" + boolean_selector: + dependency: transitive + description: + name: boolean_selector + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.0" + characters: + dependency: transitive + description: + name: characters + url: "https://pub.dartlang.org" + source: hosted + version: "1.2.1" + clock: + dependency: transitive + description: + name: clock + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.1" + collection: + dependency: transitive + description: + name: collection + url: "https://pub.dartlang.org" + source: hosted + version: "1.16.0" + fake_async: + dependency: transitive + description: + name: fake_async + url: "https://pub.dartlang.org" + source: hosted + version: "1.3.1" + flutter: + dependency: "direct main" + description: flutter + source: sdk + version: "0.0.0" + flutter_lints: + dependency: "direct dev" + description: + name: flutter_lints + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.1" + flutter_test: + dependency: "direct dev" + description: flutter + source: sdk + version: "0.0.0" + lints: + dependency: transitive + description: + name: lints + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.1" + matcher: + dependency: transitive + description: + name: matcher + url: "https://pub.dartlang.org" + source: hosted + version: "0.12.12" + material_color_utilities: + dependency: transitive + description: + name: material_color_utilities + url: "https://pub.dartlang.org" + source: hosted + version: "0.1.5" + meta: + dependency: transitive + description: + name: meta + url: "https://pub.dartlang.org" + source: hosted + version: "1.8.0" + path: + dependency: transitive + description: + name: path + url: "https://pub.dartlang.org" + source: hosted + version: "1.8.2" + sky_engine: + dependency: transitive + description: flutter + source: sdk + version: "0.0.99" + source_span: + dependency: transitive + description: + name: source_span + url: "https://pub.dartlang.org" + source: hosted + version: "1.9.0" + stack_trace: + dependency: transitive + description: + name: stack_trace + url: "https://pub.dartlang.org" + source: hosted + version: "1.10.0" + stream_channel: + dependency: transitive + description: + name: stream_channel + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.0" + string_scanner: + dependency: transitive + description: + name: string_scanner + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.1" + term_glyph: + dependency: transitive + description: + name: term_glyph + url: "https://pub.dartlang.org" + source: hosted + version: "1.2.1" + test_api: + dependency: transitive + description: + name: test_api + url: "https://pub.dartlang.org" + source: hosted + version: "0.4.12" + vector_math: + dependency: transitive + description: + name: vector_math + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.2" +sdks: + dart: ">=2.18.1 <3.0.0" + flutter: ">=1.17.0" diff --git a/pubspec.yaml b/pubspec.yaml new file mode 100644 index 0000000..422f7fd --- /dev/null +++ b/pubspec.yaml @@ -0,0 +1,54 @@ +name: type_saving_wait +description: It is not really convenient to use Future.wait, cause it's leading to type erasing, so this lib created to help you save types while use Future.wait feature. +version: 0.0.1 +homepage: https://github.com/idapgroup/type_saving_wait + +environment: + sdk: '>=2.18.1 <3.0.0' + flutter: ">=1.17.0" + +dependencies: + flutter: + sdk: flutter + +dev_dependencies: + flutter_test: + sdk: flutter + flutter_lints: ^2.0.0 + +# For information on the generic Dart part of this file, see the +# following page: https://dart.dev/tools/pub/pubspec + +# The following section is specific to Flutter packages. +flutter: + + # To add assets to your package, add an assets section, like this: + # assets: + # - images/a_dot_burr.jpeg + # - images/a_dot_ham.jpeg + # + # For details regarding assets in packages, see + # https://flutter.dev/assets-and-images/#from-packages + # + # An image asset can refer to one or more resolution-specific "variants", see + # https://flutter.dev/assets-and-images/#resolution-aware + + # To add custom fonts to your package, add a fonts section here, + # in this "flutter" section. Each entry in this list should have a + # "family" key with the font family name, and a "fonts" key with a + # list giving the asset and other descriptors for the font. For + # example: + # fonts: + # - family: Schyler + # fonts: + # - asset: fonts/Schyler-Regular.ttf + # - asset: fonts/Schyler-Italic.ttf + # style: italic + # - family: Trajan Pro + # fonts: + # - asset: fonts/TrajanPro.ttf + # - asset: fonts/TrajanPro_Bold.ttf + # weight: 700 + # + # For details regarding fonts in packages, see + # https://flutter.dev/custom-fonts/#from-packages diff --git a/test/type_saving_wait_test.dart b/test/type_saving_wait_test.dart new file mode 100644 index 0000000..436e7e8 --- /dev/null +++ b/test/type_saving_wait_test.dart @@ -0,0 +1,3 @@ +void main() { + //TODO: write tests +} diff --git a/type_saving_wait.iml b/type_saving_wait.iml new file mode 100644 index 0000000..6048a33 --- /dev/null +++ b/type_saving_wait.iml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file

p, + ) { + return Future.wait( + [ + a, + b, + c, + d, + e, + f, + g, + h, + j, + k, + l, + m, + n, + p, + ], + ).then( + (value) => FutureResult14( + value[0] as A, + value[1] as B, + value[2] as C, + value[3] as D, + value[4] as E, + value[5] as F, + value[6] as G, + value[7] as H, + value[8] as J, + value[9] as K, + value[10] as L, + value[11] as M, + value[12] as N, + value[13] as P, + ), + ); + } + + ///Function for save 15 arguments types + static Future> + wait15( + Future a, + Future b, + Future c, + Future d, + Future e, + Future f, + Future g, + Future h, + Future j, + Future k, + Future l, + Future m, + Future n, + Future