getLoginFlows method

Future<List<LoginFlow>?> getLoginFlows()

Gets the homeserver's supported login types to authenticate users. Clients should pick one of these and supply it as the type when logging in.

returns flows: The homeserver's supported login types

Implementation

Future<List<LoginFlow>?> getLoginFlows() async {
  final requestUri = Uri(path: '_matrix/client/v3/login');
  final request = Request('GET', baseUri!.resolveUri(requestUri));
  final response = await httpClient.send(request);
  final responseBody = await response.stream.toBytes();
  if (response.statusCode != 200) unexpectedResponse(response, responseBody);
  final responseString = utf8.decode(responseBody);
  final json = jsonDecode(responseString);
  return ((v) => v != null
      ? (v as List)
          .map((v) => LoginFlow.fromJson(v as Map<String, Object?>))
          .toList()
      : null)(json['flows']);
}