26 lines
698 B
Dart
26 lines
698 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();
|
|
}
|
|
}
|