What is Flutter?
Flutter was introduced by Google and it represents an open-source UI software development kit. This means you can use one programming language and one codebase to create two applications for different platforms (iOS and Android).
Do the following steps to get started with this guide:
- Create a 46elks account.
- Get a virtual phone number.
- Download the project's source code.
- Set up Flutter.
Install Flutter and choose if you want to use the Android setup or the iOS setup (you only need one).
Configure the app
Before we can make a phone call we need to configure our app.
Open the file
/lib/main.dartin the project's source code. You will see a code block looking like this:
On row 3 and 4 change the
passwordto your own API credentials for the 46elks API.
On row 8 add your virtual phone number. (Be sure to add the number in the E.164 format)
Run the app
Now we are going to run our Flutter app on a virtual device. The steps differ depending on what setup you use. Select on of the alternatives below and follow the corresponding steps:
iOS (Mac terminal)
- Open the terminal and navigate to the project you downloaded:
- Open an iOS simulator:
open -a Simulator
- Run your flutter application:
Android (Android studio)
Open the Android Emulator.
Run the sample.
Make a phone call
When the app opens up in your simulator from the previous step, you will see one field and a submit button.
Enter the phone number you wish to call in the field. Remember to write the number in the E.164 format. For testing purposes you can enter your own number (not your virtual one - your real one).
Click on the submit button.
After submitting, you will receive the status of your phone call from the 46elks API. The owner of the phone number you entered earlier (presumably yourself), will receive the phone call on their physical device and have an audio file played to them.
Now that you have successfully made your first phone call via your Flutter app, let the creativity flow.
The use of an audio file was just an example of what you can do. To change this behaviour, let's have a look at the code again.
On row 10, you will see a property called
play. This is a so called call action that is responsible for playing sounds. The 46elks API have several different call actions to play around with. Feel free to explore our documentation to see what else is possible.
Have fun developing your app with Flutter and 46elks.