62 lines
1.5 KiB
Dart
62 lines
1.5 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'dart:async';
|
|
|
|
import 'package:liblinphone_flutter/liblinphone_flutter.dart';
|
|
|
|
void main() {
|
|
runApp(const MyApp());
|
|
}
|
|
|
|
class MyApp extends StatefulWidget {
|
|
const MyApp({super.key});
|
|
|
|
@override
|
|
State<MyApp> createState() => _MyAppState();
|
|
}
|
|
|
|
class _MyAppState extends State<MyApp> {
|
|
final _liblinphoneFlutterPlugin = LiblinphoneFlutter();
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
initPlatformState();
|
|
}
|
|
|
|
Future<void> initPlatformState() async {
|
|
if (!mounted) return;
|
|
|
|
setState(() {});
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return MaterialApp(
|
|
home: Scaffold(
|
|
appBar: AppBar(title: const Text('Plugin example app')),
|
|
body: Column(
|
|
children: [
|
|
StreamBuilder(
|
|
stream: _liblinphoneFlutterPlugin.registrationEvents,
|
|
builder: (context, snapshot) {
|
|
return ListTile(
|
|
leading: snapshot.hasData
|
|
? const Icon(Icons.check)
|
|
: (snapshot.hasError
|
|
? const Icon(Icons.error)
|
|
: const CircularProgressIndicator()),
|
|
title: Text(
|
|
snapshot.hasData
|
|
? "${snapshot.data}"
|
|
: (snapshot.hasError ? "${snapshot.error}" : "Loading"),
|
|
),
|
|
subtitle: const Text("Registration events"),
|
|
);
|
|
},
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|