dial_videocall 0.0.6
dial_videocall: ^0.0.6 copied to clipboard
Dial VideoCall dependencies is a dependency that use OpenVidu video call service built on Flutter. This dependency run on both iOS and Android.
example/lib/main.dart
import 'package:dial_videocall/dial_videocall.dart';
import 'package:flutter/material.dart';
void main() {
runApp(MaterialApp(home: MyApp()));
}
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => new _MyAppState();
}
class _MyAppState extends State<MyApp> with WidgetsBindingObserver{
bool isOnCall;
bool isProduction;
TextEditingController _textSessionFromController;
TextEditingController _textSessionToController;
@override
void initState() {
super.initState();
isProduction = false;
isOnCall = false;
_textSessionFromController = TextEditingController(text: 'SessionWeb');
_textSessionToController = TextEditingController(text: 'SessionMobile');
// Ask for permission here
}
// Call this method when notification arrived with data sessionFrom and sessionTo
void _goToCallPage(String sessionFrom, String sessionTo){
// Always check whether user on call or not
// to prevent multiple video call
if(!isOnCall){
isOnCall = true;
if(isProduction){
// Production Environment
DialVideoCall.startVideoCall(
context: context,
sessionFrom: sessionFrom,
sessionTo: sessionTo
).then((value) => isOnCall = false);
}else{
// Development Environment
DialVideoCall.startVideoCallDev(
context: context,
sessionFrom: sessionFrom,
sessionTo: sessionTo
).then((value) => isOnCall = false);
}
}
}
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(
title: const Text('Dial Video Call Demo'),
),
drawer: Drawer(
child: ListView(
children: <Widget>[
ListTile(
title: Text("Dial Video Call Demo"),
subtitle: Text("v 0.0.1"),
),
ListTile(leading: Icon(Icons.home), title: Text("Home"),onTap:(){Navigator.of(context).pop();}),
],
)
),
body: Container(
child: SingleChildScrollView(
padding: const EdgeInsets.all(10.0),
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
SizedBox(height: 10),
TextField(
controller: _textSessionFromController,
decoration: InputDecoration(
contentPadding: EdgeInsets.all(5),
border: OutlineInputBorder(),
labelText: 'Session from',
hintText: 'Enter session from'
),
),
SizedBox(height: 10),
TextField(
controller: _textSessionToController,
decoration: InputDecoration(
contentPadding: EdgeInsets.all(5),
border: OutlineInputBorder(),
labelText: 'Session to',
hintText: 'Enter session to'
),
),
SizedBox(height: 10),
Row(
crossAxisAlignment: CrossAxisAlignment.center,
children:[
Text("Production Server : "),
Switch(
value: isProduction,
onChanged: (status) {
setState(() {
isProduction = status;
});
}
),
]
),
SizedBox(
height: 30,
),
ElevatedButton(
onPressed: () => _goToCallPage(_textSessionFromController.text, _textSessionToController.text),
child: Text('Join Video Call'),
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all(Colors.green),
foregroundColor: MaterialStateProperty.all(Colors.white)
),
)
],
),
),
),
),
);
}
}