Экран переключения валюты открывается с первого раза, соединение с базой данных не открывается на тех экранах, на которых это не требуется

This commit is contained in:
kifio
2017-09-12 00:08:13 +03:00
parent 9e4cbe200d
commit e8788f72a3
8 changed files with 98 additions and 81 deletions

View File

@@ -219,10 +219,17 @@ class PurchaseScreenState<T> extends BaseState<PurchaseScreen> {
httpClient.post(url, body: body, headers: headers).then((response) {
print(response.body);
helper.close().then((_) {
Navigator.of(context).pop();
pushRouteReplacement(context, new PurchaseSuccessScreen(sumTotal, user['first_name'] == null ? '' : user['first_name']));
});
Map parsedMap = JSON.decode(response.body);
if (parsedMap.containsKey('errors')) {
List<String> errors = parsedMap['errors'];
// TODO: ПОказывать сообщение с ошибкой!
} else {
helper.close().then((_) {
Navigator.of(context).pop();
pushRouteReplacement(context, new PurchaseSuccessScreen(sumTotal, user['first_name'] == null ? '' : user['first_name']));
});
}
}).catchError((error) {
purchaseInProgress = false;