sip_ua_livekit_webrtc 1.0.1 sip_ua_livekit_webrtc: ^1.0.1 copied to clipboard
A SIP UA stack for Flutter/Dart, based on flutter-webrtc, support iOS/Android/Destkop/Web.
import 'package:dart_sip_ua_example/src/theme_provider.dart';
import 'package:flutter/foundation.dart'
show debugDefaultTargetPlatformOverride;
import 'package:flutter/material.dart';
import 'package:flutter_livekit_webrtc/flutter_livekit_webrtc.dart';
import 'package:sip_ua_livekit_webrtc/sip_ua_livekit_webrtc.dart';
import 'package:logger/logger.dart';
import 'package:provider/provider.dart';
import 'src/about.dart';
import 'src/callscreen.dart';
import 'src/dialpad.dart';
import 'src/register.dart';
void main() {
Logger.level = Level.warning;
if (WebRTC.platformIsDesktop) {
debugDefaultTargetPlatformOverride = TargetPlatform.fuchsia;
}
runApp(
MultiProvider(
providers: [ChangeNotifierProvider(create: (_) => ThemeProvider())],
child: MyApp(),
),
);
}
typedef PageContentBuilder = Widget Function(
[SIPUAHelper? helper, Object? arguments]);
// ignore: must_be_immutable
class MyApp extends StatelessWidget {
final SIPUAHelper _helper = SIPUAHelper();
Map<String, PageContentBuilder> routes = {
'/': ([SIPUAHelper? helper, Object? arguments]) => DialPadWidget(helper),
'/register': ([SIPUAHelper? helper, Object? arguments]) =>
RegisterWidget(helper),
'/callscreen': ([SIPUAHelper? helper, Object? arguments]) =>
CallScreenWidget(helper, arguments as Call?),
'/about': ([SIPUAHelper? helper, Object? arguments]) => AboutWidget(),
};
Route<dynamic>? _onGenerateRoute(RouteSettings settings) {
final String? name = settings.name;
final PageContentBuilder? pageContentBuilder = routes[name!];
if (pageContentBuilder != null) {
if (settings.arguments != null) {
final Route route = MaterialPageRoute<Widget>(
builder: (context) =>
pageContentBuilder(_helper, settings.arguments));
return route;
} else {
final Route route = MaterialPageRoute<Widget>(
builder: (context) => pageContentBuilder(_helper));
return route;
}
}
return null;
}
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: Provider.of<ThemeProvider>(context).currentTheme,
initialRoute: '/',
onGenerateRoute: _onGenerateRoute,
);
}
}