app_call_button 0.0.22
app_call_button: ^0.0.22 copied to clipboard
A Flutter plugin that provides in-app call functionality using SIP and WebRTC for both Android and iOS.
example/lib/main.dart
import 'package:app_call_button/app_call_button.dart';
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
// @override
// void initState() {
// super.initState();
// AppSipController.instance.init();
// }
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Plugin Test App',
builder: (context, child) {
return FlutterOverlayManager.I.builder((ctx) => child!);
},
home: Scaffold(
appBar: AppBar(title: const Text('AppCallButton Test')),
backgroundColor: Colors.white,
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
ValueListenableBuilder(
valueListenable: AppSipController.instance.sipData,
builder: (context, call, _) {
return Text("Call To: ${call.callTo}");
},
),
SizedBox(height: 10),
// Duaration
ValueListenableBuilder(
valueListenable: AppSipController.instance.callDuration,
builder: (context, callDuaration, _) {
return Text("Call Duaration: $callDuaration");
},
),
SizedBox(height: 10),
ValueListenableBuilder(
valueListenable: AppSipController.instance.sipStarted,
builder: (context, isStart, _) {
return Column(
children: [
SizedBox(height: 10),
Divider(),
Opacity(
opacity: isStart ? 0.5 : 1,
child: ElevatedButton(
onPressed: () {
isStart
? null
: AppSipController.instance.register();
},
child: const Text("Register"),
),
),
Divider(),
Opacity(
opacity: isStart ? 1 : 0.5,
child: ElevatedButton(
onPressed: () {
//Use AppSipController.instance.makeCall to make a call (no UI included).
//You can create your own UI, or use AppSipController.instance.showCallOverlay
//to display the default call screen.
isStart
? AppSipController.instance.makeCall()
: null;
},
child: const Text("Call Now"),
),
),
SizedBox(height: 20),
Text("OR"),
SizedBox(height: 20),
Opacity(
opacity: isStart ? 1 : 0.5,
child: ElevatedButton(
onPressed: () {
isStart
? AppSipController.instance.showCallOverlay()
: null;
},
child: const Text("Go To Call Screen Default"),
),
),
Divider(),
SizedBox(height: 10),
// call to
ValueListenableBuilder(
valueListenable: AppSipController.instance.currentCall,
builder: (context, currentCall, _) {
return Opacity(
opacity: isStart && currentCall != null ? 1 : 0.5,
child: ElevatedButton(
onPressed: () {
isStart
? AppSipController.instance.endCall()
: null;
},
child: const Text("End Call"),
),
);
},
),
],
);
},
),
],
),
),
),
);
}
}