Created
October 25, 2019 14:38
-
-
Save incker/bdf50c9717a0d2ef1083cc5ae4b84da7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'dart:async'; | |
import 'dart:convert'; | |
void main() { | |
Future<String> queryOne() async { | |
return "[1,2,3]"; | |
} | |
Future<String> queryTwo() async { | |
return "{\"test\":true}"; | |
} | |
T parseJson<T>(String resp) { | |
const json = const JsonCodec(); | |
return json.decode(resp); | |
} | |
// THIS IS COMPILING | |
Future<Map<String, dynamic>> isCompiningOk() { | |
return queryOne().then(parseJson); | |
}; | |
// THIS IS NOT | |
queryOne().then(parseJson).then((Map<String, dynamic> onValue) { | |
return 1; | |
}); | |
for (int i = 0; i < 5; i++) { | |
print('hello ${i + 1}'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment