Skip to content

Instantly share code, notes, and snippets.

@enyo
Last active October 1, 2021 09:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save enyo/5647960687d8c805dcd1c30055d54f28 to your computer and use it in GitHub Desktop.
Save enyo/5647960687d8c805dcd1c30055d54f28 to your computer and use it in GitHub Desktop.
/// A channel that the gRPC libray communicates over.
/// This is provided by the gRPC library.
final channel = GrpcWebClientChannel.xhr(Uri.parse('https://your.api.url:8080'));
/// The class [AccountServiceClient] is generated by the gRPC library from
/// your `.proto` definition.
final client = AccountServiceClient(channel);
Future<void> changePassword() async {
/// The message you want to send to the API. It's also generated from your
/// `.proto` definition.
final request =
ChangePasswordRequest(oldPassword: 'old-pass', newPassword: 'new-pass');
/// Simply call the `.changePassword()` method on your client as if it were
/// a local call, and you get the response from the server asynchronously.
///
/// In this case the call doesn't return anything.
await client.changePassword(request);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment