flutter_phone_call_state 0.0.4 copy "flutter_phone_call_state: ^0.0.4" to clipboard
flutter_phone_call_state: ^0.0.4 copied to clipboard

This Flutter plugin allows you to track and manage phone call states on Android and iOS devices. It helps you monitor the current state of a call (incoming, outgoing, accepted, or ended) and provides [...]

example/lib/main.dart

import 'package:flutter/material.dart';
import 'dart:async';
import 'package:flutter_phone_call_state/flutter_phone_call_state.dart';
import 'package:url_launcher/url_launcher_string.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 _phoneCallStatePlugin = PhoneCallState.instance;
  String status = 'none';

  @override
  void initState() {
    super.initState();
    subscriptionPhoneCallStateChange();
  }

  void subscriptionPhoneCallStateChange() async {
    _phoneCallStatePlugin.phoneStateChange.listen(
      (event) {
        switch(event.state){
          case CallState.end:
            // TODO: Handle this case.
          case CallState.outgoing:
            // TODO: Handle this case.
          case CallState.outgoingAccept:
            // TODO: Handle this case.
          case CallState.incoming:
            // TODO: Handle this case.
          case CallState.call:
            // TODO: Handle this case.
          case CallState.none:
            // TODO: Handle this case.
        }

        debugPrint(
            "Phone Number: ${event.number} <------> Phone Status:${event.state.name}");

        scheduleMicrotask(() {
          setState(() {
            status = '${event.state.name}: ${event.number}';
          });
        });
      },
    );
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Column(
          children: [
            InkWell(
              child: const Text("tell:0824112873"),
              onTap: () async {
                ///call here
                await launchUrlString("tel://0824112873");
              },
            ),
            Center(
              child: Text('Phone status: $status\n'),
            ),
          ],
        ),
      ),
    );
  }
}
0
likes
150
points
49
downloads

Publisher

unverified uploader

Weekly Downloads

This Flutter plugin allows you to track and manage phone call states on Android and iOS devices. It helps you monitor the current state of a call (incoming, outgoing, accepted, or ended) and provides real-time updates.

Homepage
Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on flutter_phone_call_state