Manu Abhay Singhal
2 min readFeb 13, 2021

Flutter Voice Messaging App.

In this article we will see how to implement Whatsapp like voice messaging feature in our chat app.

Prerequisite:

  • Firebase Project
  • Flutter App connected to firebase project
  • Enable Google Sign In (remember to add SHA keys to the project)

Step 1:

Get the the dependencies in the pubsec.yaml file. You can get all these on https://pub.dev

All the dependencies we needed

Step 2: Creating the sign in page.

Since our focus is on show voice message functionality we’ll make simple login page.

First we have to initialize Firebase in our flutter app main.dart file.

After the Initialization, we will add our sign in code as our logic to check if user already signed in or not.

Functions to handle Google Sign In

Step3: Creating the Home Page

Our home page will be populated with other user-IDs which are signed in our app other than current user-ID.

Complete Code for Home Screen shown below
Home Page

Step 4: Creating the chat page

First we will get the chat room-ID from Shared Preferences to get all messages between friends user-ID and current user-ID.

Function to get Chat Room-ID

Now we’ll write code to start, stop and play the voice message, for this we will need to import record_mp3, audioplayers, path, permission_handler and path_provider libraries in chat.dart page

Functions to Start, Stop and Play Voice messages.

Now we’ll need to send these voice messages to our friend, for this we need to import firebase_storage library. First we’ll upload the voice message to firebase storage and send the URL of voice message returned by the upload function in the content field while sending or saving the message in cloud Firestore.

Functions to Upload and Send Voice as well as Text messages

Now finally we’ll build the UI of conversation , timestamp we’ll be used as message id.

UI Code for One Message Bubble

With this we have completed all the code snippets, now lets combine all this together and build it.

Complete code for Chat Screen shown below
Chat Screen

To view the complete Project head on to https://github.com/abhay1205/voiceChatApp and give a star if found it helpful.

In the next part we’ll see how to implement Whatsapp audio and video call feature and search functionality. Till then Namaste

Manu Abhay Singhal
Manu Abhay Singhal

Written by Manu Abhay Singhal

Full Time Student at Manipal University Jaipur and passion time Flutter and NodeJS Developer

No responses yet