login method

Future<String> login(
  1. String email,
  2. String password
)

Returns the token or throws an error

Implementation

Future<String> login(String email, String password) async {
  try {
    final request = LoginRequest()
      ..email = email
      ..password = password;

    final response = await _stub.login(request);
    if (response.success) {
      return response.token;
    }
    final err = ('Login failed: ${response.message}');
    throw err;
  } catch (e) {
    final err = ('Error during login: $e');
    throw err;
  }
}