Created
October 25, 2019 14:25
-
-
Save incker/0bed8f761fdcf789629b1ecd783846ca 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(); | |
try { | |
return json.decode(resp); | |
} catch (e) { | |
print('Some error on parsing json: $e'); | |
return null; | |
} | |
print('Invalid resp: $resp'); | |
return null; | |
} | |
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