logoutCurrentUser static method

Future<void> logoutCurrentUser({
  1. MBManager? manager,
})

Logs out the current user.

  • Parameters:
    • manager: An optional MBManager used to make calls instead of MBManager.shared.
  • Returns a Future that completes when the user is logged out correctly.

Implementation

static Future<void> logoutCurrentUser({
  MBManager? manager,
}) async {
  MBManager mbManager = manager ?? MBManager.shared;

  String apiName = 'api/logout';

  var uri = Uri.https(mbManager.endpoint, apiName);

  var requestBody = json.encode(await mbManager.defaultParameters());

  Map<String, String> headers =
      await mbManager.headers(contentTypeJson: true);

  http.Response response = await http.post(
    uri,
    headers: headers,
    body: requestBody,
  );

  MBManager.checkResponse(response.body, checkBody: false);

  await _setUserLoggedOut();
}