Zenith/lib/zenith_client_provider.dart

26 lines
723 B
Dart

import 'package:flutter/material.dart';
import 'package:matrix/matrix.dart';
class ZenithClientProvider extends ChangeNotifier {
late Client _client;
Client get client => _client;
void setClient(Client newClient) {
_client = newClient;
notifyListeners();
}
Future<void> initialize(
String homeserver, String username, String password) async {
_client = Client("zenith");
print("Checking homeserver...");
await client.checkHomeserver(Uri.parse(homeserver));
print("Logging in...");
await client.login(LoginType.mLoginPassword,
identifier: AuthenticationUserIdentifier(user: username),
password: password);
notifyListeners();
}
}