Interacting with the complete Dapp

  1. Now we’re ready to use our dapp!
  2. Just RUN the Flutter Project.

As you can see the countryName (Unknown) and currentPopulation (0) is actually coming from the smart-contract, which we’d set in the constructor of our smart contract.

When you click on the floatingActionButton , it will push the current route to SetPopulation().

  1. You can define the countryName and currentPopulation here.
  2. When you click on save, the specified name and population will be actually added to the blockchain.

  • You can Increase or Decrease the currentPopulation by just click on the ElevatedButton as specified.

Congratulations! You have taken a huge step to become a full-fledged mobile dapp developer. For developing locally, you have all the tools you need to start making more advanced dapps.

If you stuck somewhere, do check out the GitHub repository for complete code.



Flutter and Blockchain – Population Dapp

Before checking out this article, Do take a look at Flutter and Blockchain – Hello World Dapp. This tutorial will take you through the process of building your mobile dapp – Population on Blockchain!

This tutorial is meant for those with a basic knowledge of Ethereum and smart contracts, who have some knowledge of the Flutter framework but are new to mobile dapps.

In this tutorial we will be covering:

  1. Setting up the development environment
  2. Creating a Truffle Project
  3. Writing the Smart Contract
  4. Compiling and Migrating the Smart Contract
  5. Testing the Smart Contract
  6. Contract linking with Flutter
  7. Creating a UI to interact with the smart contract
  8. Interacting with the complete Dapp

Description

Population on blockchain is a simple decentralized application, which will allow you to store a specific country population on the blockchain, you can increment as well as decrement the population based on the current condition of the country.

Output:

Similar Reads

Setting up the development environment

Truffle is the most popular development framework for Ethereum with a mission to make your life a whole lot easier. But before we install truffle make sure to install node ....

Creating a Truffle Project

Create a basic Flutter project in your favorite IDE Initialize Truffle in the flutter project directory by running...

Writing the Smart Contract

The Smart Contract actually acts as the back-end logic and storage for our Dapp....

Compiling and Migrating

...

Testing the Smart Contract

...

Contract linking with Flutter

...

Creating a UI to interact with the smart contract

...

Interacting with the complete Dapp

Compilation...