register method

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

Returns the token or throws an error

Implementation

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

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