2/22/1
This commit is contained in:
@@ -1,12 +1,15 @@
|
||||
import 'dart:async';
|
||||
import 'package:SEFER/constant/box_name.dart';
|
||||
import 'package:SEFER/main.dart';
|
||||
import 'package:SEFER/views/widgets/my_scafold.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:permission_handler/permission_handler.dart';
|
||||
|
||||
import 'package:agora_rtc_engine/agora_rtc_engine.dart';
|
||||
|
||||
import '../../../../constant/api_key.dart';
|
||||
import '../../../../controller/functions/crud.dart';
|
||||
|
||||
const String appId = AK.agoraAppId;
|
||||
|
||||
@@ -18,9 +21,9 @@ class DriverCallPage extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _DriverCallPageState extends State<DriverCallPage> {
|
||||
String channelName = 'sefer300';
|
||||
String token =
|
||||
"00612994c6e707543e68d5638894d04f989IAACchY2SBwRcuw2mt+BocxbF+fmFKvjOS/hekkirRWfuqMLiA8AAAAAEADs3TvfbjrSZQEAAQAAAAAA";
|
||||
String channelName = '';
|
||||
String token = '';
|
||||
// "00612994c6e707543e68d5638894d04f989IAAlydoFEC3ZeZkeUwl0dSswZTX8n+xyZR8PBWdwXFV6t6MLiA8AAAAAEACCHD/gn3TUZQEAAQAAAAAA";
|
||||
|
||||
// int uid = int.parse(box.read(BoxName.phoneDriver)); // uid of the local user
|
||||
int uid = 0;
|
||||
@@ -37,6 +40,20 @@ class _DriverCallPageState extends State<DriverCallPage> {
|
||||
));
|
||||
}
|
||||
|
||||
initAgora() async {
|
||||
await fetchToken();
|
||||
await setupVoiceSDKEngine();
|
||||
}
|
||||
|
||||
fetchToken() async {
|
||||
var res = await CRUD()
|
||||
.getAgoraToken(channelName: channelName, uid: uid.toString());
|
||||
setState(() {
|
||||
token = res;
|
||||
print('token is $token');
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
@@ -49,7 +66,7 @@ class _DriverCallPageState extends State<DriverCallPage> {
|
||||
print('remoteid is $_remoteUid');
|
||||
print('uid is $uid');
|
||||
// Set up an instance of Agora engine
|
||||
setupVoiceSDKEngine();
|
||||
initAgora();
|
||||
}
|
||||
|
||||
Future<void> setupVoiceSDKEngine() async {
|
||||
@@ -124,35 +141,39 @@ class _DriverCallPageState extends State<DriverCallPage> {
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
scaffoldMessengerKey: scaffoldMessengerKey,
|
||||
home: Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Get started with Voice Calling'),
|
||||
),
|
||||
body: ListView(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 4),
|
||||
children: [
|
||||
// Status text
|
||||
Container(height: 40, child: Center(child: _status())),
|
||||
// Button Row
|
||||
Row(
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
child: ElevatedButton(
|
||||
child: const Text("Join"),
|
||||
onPressed: () => {join()},
|
||||
home: MyScafolld(
|
||||
// appBar: AppBar(
|
||||
// title: const Text('Get started with Voice Calling'),
|
||||
// ),
|
||||
title: 'Voice Calling'.tr,
|
||||
isleading: true,
|
||||
body: [
|
||||
ListView(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 4),
|
||||
children: [
|
||||
// Status text
|
||||
Container(height: 40, child: Center(child: _status())),
|
||||
// Button Row
|
||||
Row(
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
child: ElevatedButton(
|
||||
child: const Text("Join"),
|
||||
onPressed: () => {join()},
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(
|
||||
child: ElevatedButton(
|
||||
child: const Text("Leave"),
|
||||
onPressed: () => {leave()},
|
||||
const SizedBox(width: 10),
|
||||
Expanded(
|
||||
child: ElevatedButton(
|
||||
child: const Text("Leave"),
|
||||
onPressed: () => {leave()},
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
)),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
]),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user