-
Notifications
You must be signed in to change notification settings - Fork 3
Exception has occurred. _TypeError (type 'ApiResponse' is not a subtype of type 'int?') #339
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…pe of type 'int?')
Why not change the Future<int?> createSession(Session session) async {
try {
final response = await http
.post(Uri.parse('$serverUrl$sessions'),
headers: headers,
body: json.encode(
session.toJson(),
))
.timeout(Duration(seconds: _timeoutTimerInSeconds));
if (response.statusCode == 201) {
var body = json.decode(response.body);
return body['id'] as int;
} else {
print("Error: Unexpected response code ${response.statusCode}");
print("Response body: ${response.body}");
}
} on TimeoutException {
print("Error: Request timed out.");
} on http.ClientException catch (e) {
print("HTTP Client Exception: $e");
} catch (e) {
print("Error : ${e}");
}
return null;
} So then the Session session = Session(
session_ID: sessionId,
user: userUUID,
session_start_time: DateTime.now().toUtc().toIso8601String());
print(language);
session.id = await ApiSingleton().createSession(session); What do you think? |
I agree, I've applied your changes, except the line
because this would cause a bug, since |
lib/utils/Utils.dart
Outdated
@@ -92,13 +92,13 @@ class Utils { | |||
|
|||
int? sessionId = response + 1; | |||
|
|||
session = Session( | |||
Session session = Session( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
already defined on top
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry I hadn't pushed my last commit
No description provided.