如果你的目标平台为 iOS,你的开发环境需要满足以下需求:
如果你的目标平台为 Android,你的开发环境需要满足以下需求:
如果你的目标平台为 macOS,你的开发环境需要满足以下需求:
如果你的目标平台为 Windows,你的开发环境需要满足以下需求:
更多环境要求细节,详见 Install Flutter。
flutter doctor
命令检查开发环境和运行环境是否满足要求。一个有效的声网开发者账号。
参考以下步骤创建一个声网项目:
声网会给每个项目自动分配一个 App ID 作为项目唯一标识。
在声网控制台的项目管理页面,找到你的项目,点击 App ID 右侧的 图标,即可获取项目的 App ID。
为提高项目的安全性,声网推荐使用 Token 对即将加入频道的用户进行鉴权。
为了方便测试,声网控制台提供生成 RTC 临时 Token 的功能。参考以下步骤获取 RTC 临时 Token:
testroom
,然后点击生成。后续调用 API 加入频道时,请确保填入的频道名与这里的频道名一致。下载 Agora-Flutter-SDK 仓库。使用 Visual Studio Code 打开 agora.config.dart
(example/lib/config/agora.config.dart
)文件并添加以下参数:
将 YOUR_APP_ID
替换为你的声网 App ID。类型为字符串。
将 YOUR_TOEKN
替换为你的 Token。类型为字符串。
将 YOUR_CHANNEL_ID
替换为你的 RTC 频道 ID。类型为字符串,例如:"test_channel"
。
将 YOUR_UID
替换为你的 RTC uid,必须和生成 Token 时使用的 uid 相同。类型为整数,例如:1234
。
将 YOUR_STRING_UID
替换为空字符串 ""。
/// Get your own App ID at https://dashboard.agora.io/
const appId = YOUR_APP_ID;
/// Please refer to https://docs.agora.io/en/Agora%20Platform/token
const token = YOUR_TOEKN;
/// Your channel ID
const channelId = YOUR_CHANNEL_ID;
/// Your int user ID
const uid = YOUR_UID;
/// Your string user ID
const stringUid = YOUR_STRING_UID;
在仓库根目录运行以下命令安装依赖项。
flutter packages get
在 Visual Studio Code 右下角状态栏选择需要运行项目的设备。运行以下命令启动示例项目。
flutter run