sip_ua 0.5.2 sip_ua: ^0.5.2 copied to clipboard
A SIP UA stack for Flutter/Dart, based on flutter-webrtc, support iOS/Android/Destkop/Web.
import 'package:flutter/foundation.dart'
show debugDefaultTargetPlatformOverride;
import 'package:flutter/material.dart';
import 'package:flutter_webrtc/flutter_webrtc.dart';
import 'package:sip_ua/sip_ua.dart';
import 'src/about.dart';
import 'src/callscreen.dart';
import 'src/dialpad.dart';
import 'src/register.dart';
void main() {
if (WebRTC.platformIsDesktop) {
debugDefaultTargetPlatformOverride = TargetPlatform.fuchsia;
}
runApp(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: ThemeData(
primarySwatch: Colors.blue,
fontFamily: 'Roboto',
),
initialRoute: '/',
onGenerateRoute: _onGenerateRoute,
);
}
}