medea_flutter_webrtc 0.8.0-dev+rev.6749e566134dd8a11e0080b7cc1fabcfcad6e6f3 medea_flutter_webrtc: ^0.8.0-dev+rev.6749e566134dd8a11e0080b7cc1fabcfcad6e6f3 copied to clipboard
Flutter WebRTC plugin for iOS/Android/Desktop/Web, based on GoogleWebRTC.
import 'dart:core';
import 'package:flutter/material.dart';
import 'src/create_peer_connection.dart';
import 'src/get_display_media.dart';
import 'src/get_sources.dart';
import 'src/get_user_media.dart'
if (dart.library.html) 'src/get_user_media_sample_web.dart';
import 'src/loopback.dart';
import 'src/on_device_change.dart';
import 'src/route_item.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({Key? key}) : super(key: key);
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
late List<RouteItem> items;
@override
void initState() {
super.initState();
_initItems();
}
ListBody _buildRow(context, item) {
return ListBody(children: <Widget>[
ListTile(
title: Text(item.title),
onTap: () => item.push(context),
trailing: const Icon(Icons.arrow_right),
),
const Divider()
]);
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Flutter-WebRTC example'),
),
body: ListView.builder(
shrinkWrap: true,
padding: const EdgeInsets.all(0.0),
itemCount: items.length,
itemBuilder: (context, i) {
return _buildRow(context, items[i]);
})),
);
}
void _initItems() {
items = <RouteItem>[
RouteItem(
title: 'GetUserMedia',
push: (BuildContext context) {
Navigator.push(
context,
MaterialPageRoute(
builder: (BuildContext context) =>
const GetUserMediaSample()));
}),
RouteItem(
title: 'GetDisplayMedia',
push: (BuildContext context) {
Navigator.push(
context,
MaterialPageRoute(
builder: (BuildContext context) =>
const GetDisplayMediaSample()));
}),
RouteItem(
title: 'LoopBack Sample',
push: (BuildContext context) {
Navigator.push(
context,
MaterialPageRoute(
builder: (BuildContext context) => const Loopback()));
}),
RouteItem(
title: 'getSources',
push: (BuildContext context) {
Navigator.push(
context,
MaterialPageRoute(
builder: (BuildContext context) =>
const GetSourcesSample()));
}),
RouteItem(
title: 'Basic RtcPeerConnection',
push: (BuildContext context) {
Navigator.push(
context,
MaterialPageRoute(
builder: (BuildContext context) =>
const PeerConnectionSample()));
}),
RouteItem(
title: 'onDeviceChange notifier',
push: (BuildContext context) {
Navigator.push(
context,
MaterialPageRoute(
builder: (BuildContext context) =>
const OnDeviceChangeNotifierSample()));
}),
];
}
}