sip_ua 0.2.4 sip_ua: ^0.2.4 copied to clipboard
A dart-lang version of the SIP UA stack.
import 'package:flutter/foundation.dart'
show debugDefaultTargetPlatformOverride;
import 'package:flutter/material.dart';
import 'package:sip_ua/sip_ua.dart';
import 'package:flutter_webrtc/webrtc.dart';
import 'src/register.dart';
import 'src/dialpad.dart';
import 'src/callscreen.dart';
import 'src/about.dart';
void main() {
if (WebRTC.platformIsDesktop) {
debugDefaultTargetPlatformOverride = TargetPlatform.fuchsia;
}
runApp(MyApp());
}
typedef PageContentBuilder = Widget Function(
[SIPUAHelper helper, Object arguments]);
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;
}
}
}
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
fontFamily: 'Roboto',
),
initialRoute: '/',
onGenerateRoute: _onGenerateRoute,
);
}
}