flutter_vonage_opentok 1.7.0 copy "flutter_vonage_opentok: ^1.7.0" to clipboard
flutter_vonage_opentok: ^1.7.0 copied to clipboard

Flutter plugin for Vonage OpenTok SDK

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:flutter_vonage_opentok/flutter_vonage_opentok.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();

  await Future.delayed(const Duration(seconds: 1));

  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  final _opentok = const FlutterVonageOpentok();

  Publisher? publisher;

  Future<void> _init() async {
    try {
      final granted = await _opentok.requestPermissions();

      if (!granted) {
        return;
      }

      publisher = await _opentok.initPublisher();

      final session = _opentok.initSession(
        apiKey: '',
        sessionId: '',
        token: '',
        publisher: publisher!,
      );

      await session.connect();

      await session.publish();
    } catch (e) {
      debugPrint(e.toString());
    }
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: Text(widget.title),
      ),
      body: Stack(
        fit: StackFit.expand,
        children: [
          Center(
            child: PlatformDivElement(
              DivProps.publisher(afterCreate: _init),
            ),
          ),
          Positioned(
            bottom: 0,
            right: 0,
            width: 500,
            height: 500,
            child: PlatformDivElement(
              DivProps.subscriber(),
            ),
          ),
        ],
      ),
    );
  }
}
1
likes
140
points
401
downloads

Publisher

unverified uploader

Weekly Downloads

Flutter plugin for Vonage OpenTok SDK

Documentation

API reference

License

MIT (license)

Dependencies

flutter, flutter_vonage_opentok_platform_interface, flutter_vonage_opentok_web, permission_handler

More

Packages that depend on flutter_vonage_opentok