Logout works
all that needs doing now is 'save login'
This commit is contained in:
parent
e3ca987aa8
commit
fef1621d3e
4 changed files with 15 additions and 9 deletions
|
@ -1,5 +1,5 @@
|
|||
import 'dart:io';
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
|
@ -16,12 +16,18 @@ Future<LoginModel> requestLogoutAPI(BuildContext context) async {
|
|||
token = result;
|
||||
});
|
||||
|
||||
Map<String, String> body = {
|
||||
"Token":token,
|
||||
};
|
||||
|
||||
final response = await http.post(
|
||||
url,
|
||||
headers: {HttpHeaders.authorizationHeader: "Token $token"},
|
||||
body: json.encode(body),
|
||||
);
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
debugPrint("Logout successful: " + response.body);
|
||||
|
||||
saveLogout();
|
||||
return null;
|
||||
} else {
|
||||
|
|
|
@ -62,10 +62,10 @@ Future<LoginModel> submitReceiptAPI(
|
|||
print(responseJson[0]);
|
||||
|
||||
showDialogSingleButton(
|
||||
context,
|
||||
responseJson[0] == "" ? responseJson[0] : "Upload Successful",
|
||||
"Transaction successfully submitted to server",
|
||||
"OK"
|
||||
context,
|
||||
responseJson[0] == "" ? responseJson[0] : "Upload Successful",
|
||||
"Transaction successfully submitted to server",
|
||||
"OK"
|
||||
);
|
||||
return LoginModel.fromJson(responseJson);
|
||||
} else {
|
||||
|
|
Reference in a new issue