Skip to content

Instantly share code, notes, and snippets.

@PlugFox
Forked from incker/main.dart
Created October 25, 2019 14:32
Show Gist options
  • Save PlugFox/51138ed9b05c91ccd77a6a8167e556aa to your computer and use it in GitHub Desktop.
Save PlugFox/51138ed9b05c91ccd77a6a8167e556aa to your computer and use it in GitHub Desktop.
Правки в парсер для @incker
// Правки в парсер для @incker
import 'dart:async';
import 'dart:convert';
Future<String> queryOne() async =>
"[1,2,3]";
Future<String> queryTwo() async =>
"{\"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;
}
}
void main() {
queryOne()
.then((String v) => parseJson<Map<String, dynamic>>(v))
.then((Map<String, dynamic> v) => 1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment