Flutter GRPC Hello World on Ubuntu

Mobile Apps Development A-Z Guide.

Volodymyr Babenko
Pharos Production
3 min readMar 19, 2019

--

Give us a message if you’re interested in Blockchain and FinTech software development or just say Hi at Pharos Production Inc.

Or follow us on Youtube to know more about Software Architecture, Distributed Systems, Blockchain, High-load Systems, Microservices, and Enterprise Design Patterns.

Pharos Production Youtube channel

“A high-performance, open-source universal RPC framework” — this is exactly what is written on the official website of GRPS. In this article, I would like to demonstrate how to write your first application on Flutter framework under the Ubuntu platform. Information for this article is largely taken from the official site.

Step1. Minimum requirements for the use of GRPS is Dart SDK version 2.0 or higher. At the time of this writing, the latest version of SDK is 2.2. Detailed installation instructions are listed at the following link. And do not forget to add the established Dart SDK to the environment variables.

To make sure everything is done correctly, enter the following command in the terminal window:

dart --version

Step 2. Install Protocol Buffers v3.

To install the protoc compiler, go to the following link and download the file with the format “protoc-<version>-<os>.zip”. In our case, we use Linux — protobuf-all-3.7.0.tar.gz. Unzip the downloaded file and place it in the

/home/<your user name>/development/

Now you need to add the downloaded compiler to the environment variables. To do this, add the following line file .bashrc

export PATH=$PATH:$HOME/<your user name>/development/protoc-3.7.0-linux-x86_64/bin

Step 3. Install the protoc plugin for Dart. Execute the following command in the terminal window.

~$ pub global activate protoc_plugin

The compiler plugin, protoc-gen-dart, is installed in $HOME/.pub-cache/bin. The address of this plugin must also be added to environment variables.

$ export PATH=$PATH:$HOME/.pub-cache/bin

Step 4. Download an example.

Everything is quite simple here. You just need to clone the project from the official repository.

git clone https://github.com/grpc/grpc-dart

To run the example, we will use only the command line. Go to the grpc-dart /example /helloworld folder and load the necessary dependencies.

$ cd grpc-dart/example/helloworld/
$ pub get

Step 5. Run an example.

In the downloaded example, there are two files, namely server.dart and client.dart

So, in one terminal we start the server.

And in other terminal lets run a client:

As you can see, we just launched a server on localhost on port 50051. And then they created a client request and received a response from the server.

Thanks for reading.

--

--