getActiveEntities method Null safety

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

Return the current active entity for the current user as a Map Reference: https://github.com/glpi-project/glpi/blob/master/apirest.md#get-active-entities

Implementation

Future<Map<String, dynamic>> getActiveEntities() 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/getActiveEntities'),
      headers: headers);

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

  return json.decode(_response.body);
}