Compile and run a sample project
Updated
Compile and run a project using Agora SDK
Agora provides Open-source sample projects on GitHub to demonstrate the implementation of basic and advanced RTC SDK features.
This page shows how to compile, configure, and run the RTC SDK Flutter sample project.
Prerequisites
-
Flutter 2.10.5 or higher with Dart 2.14.0 or higher.
-
Android Studio, IntelliJ, VS Code, or any other IDE that supports Flutter. See Set up an editor.
-
Prepare your development and testing environment according to your target platform.
Run the
flutter doctorcommand to confirm that your development environment is set up correctly for Flutter development.
-
A camera and a microphone
-
A valid Agora account and project. Please refer to Agora account management for details.
-
Installed Git
Project setup
Get the sample project
Run the following command to clone the repository locally:
git clone git@github.com:AgoraIO-Extensions/Agora-Flutter-SDK.gitThis repository contains the following sample projects for Agora Web RTC SDK:
| Description | Path |
|---|---|
| Basic functions | /example/lib/examples/basic |
| Advanced features | /example/lib/examples/advanced |
Configure the sample project
-
Install dependencies
In the project root directory, run the following command to install the dependencies:
flutter pub get -
Set the App ID and Token
Open the
/example/lib/config/agora.config.dartfile, fill in thedefaultValuefor the App ID, channel name, and temporary token you obtained from Agora Console.String get appId { return '<TEST_APP_ID>'; } String get token { return '<TEST_TOKEN>'; } String get channelId { return '<TEST_CHANNEL_ID>'; }
Run the sample project
-
Connect the target device to your computer.
-
Open terminal and navigate to the
/examplesdirectory. -
Execute the following command to launch the sample project on available devices:
flutter run -
After compilation is complete, you see the following application on your device:
-
Select a demo you want to experience from the menu. Choose JoinChannelVideo under Basic as an example. Enter the channel name you specified when generating the temporary token in Channel ID, and click Join channel.
-
To test various audio and video interaction use-cases, connect to the Agora web demo, or install and run the sample project on a second device. Make sure you use the same app ID on both devices. When you join the same channel from two devices, you can see and hear each other.
