Skip to content

Instantly share code, notes, and snippets.

@incker
Created October 25, 2019 14:38
Show Gist options
  • Save incker/bdf50c9717a0d2ef1083cc5ae4b84da7 to your computer and use it in GitHub Desktop.
Save incker/bdf50c9717a0d2ef1083cc5ae4b84da7 to your computer and use it in GitHub Desktop.
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