dial_videocall 0.0.4 copy "dial_videocall: ^0.0.4" to clipboard
dial_videocall: ^0.0.4 copied to clipboard

discontinued
outdated

Dial VideoCall using OpenVidu on Flutter

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)
                    ),
                  )
                ],
              ),
            ),
          ),
        ),
      );
  }
}
0
likes
0
points
15
downloads

Publisher

unverified uploader

Weekly Downloads

Dial VideoCall using OpenVidu on Flutter

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, flutter_webrtc, html

More

Packages that depend on dial_videocall