getMyProfiles method Null safety

Future<Map<String, dynamic>> getMyProfiles()

Return a Map of all the profil for the current user Profiles are under the key myprofiles Reference: https://github.com/glpi-project/glpi/blob/master/apirest.md#get-my-profiles.

Implementation

Future<Map<String, dynamic>> getMyProfiles() async {
  if (_sessionToken == null) {
    throw Exception('No session token, initSession first');
  }

  final Map<String, String> headers = {
    'Session-Token': _sessionToken!,
    'Content-Type': 'application/json',
    ...?appToken != null ? {'App-Token': appToken!} : null,
  };

  final _response =
      await http.get(Uri.parse('$baseUrl/getMyProfiles'), headers: headers);

  if (_response.statusCode != 200) {
    throw Exception('${_response.statusCode} ${_response.body}');
  }

  return json.decode(_response.body);
}