Это функция, содержащая запрос:
Future<String> getRequest(String serviceName, Map<String, String> a) async {
var responseBody = '{"data": "", "status": "NOK"}';
try {
http.Response response =
await http.get(_urlBase + '$_serverApi$serviceName', headings: a);
if (response.statusCode == 200) {
responseBody = response.body;
}
} catch (e) {
// An error was received
throw new Exception("GET ERROR");
}
return responseBody;
}
, и здесь я ее называю:
void _confirm() async {
if (_formKey.currentState.saveAndValidate()) {
print(_formKey.currentState.value);
Map<String, String> c =
Map<String, String>.from(_formKey.currentState.value);
// just below
var a = await auth.getRequest('se_connecter', c);
print(a);
} else {
print(_formKey.currentState.value);
print("validation failed");
}
}
каждый раз, когда я пытаюсь это сделать, код в try blo c терпит неудачу и выдает исключение (ClientException после того, как я удалил, попытайтесь поймать blo c)
Это трассировка стека исключений:
I/flutter (10979): #0 IOClient.send
package:http/src/io_client.dart:65
I/flutter (10979): <asynchronous suspension>
I/flutter (10979): #1 BaseClient._sendUnstreamed
package:http/src/base_client.dart:176
I/flutter (10979): #2 BaseClient.get
package:http/src/base_client.dart:35
I/flutter (10979): #3 get.<anonymous closure>
package:http/http.dart:46
I/flutter (10979): #4 _withClient
package:http/http.dart:166
I/flutter (10979): #5 get
package:http/http.dart:46
I/flutter (10979): #6 getRequest
package:event_app/auth.dart:125
I/flutter (10979): #7 ConnectPageState._confirm
package:event_app/pages/connect_page.dart:28
I/flutter (10979): #8 _InkResponseState._handleTap
package:flutter/…/material/ink_well.dart:706
I/flutter (10979): #9 _InkResponseState.build.<anonymous closure>
package:flutter/…/material/ink_well.dart:789
I/flutter (10979): #10 GestureRecognizer.invokeCallback
package:flutter/…/gestures/recognizer.dart:182
I/flutter (10979): #11 TapGestureRecognizer.handleTapUp
package:flutter/…/gestures/tap.dart:486
I/flutter (10979): #12 BaseTapGestureRecognizer._checkUp
package:flutter/…/gestures/tap.dart:264
I/flutter (10979): #13 BaseTapGestureRecognizer.