{"id":20340898,"url":"https://github.com/leancodepl/flutter-phone-state","last_synced_at":"2025-10-20T10:35:05.518Z","repository":{"id":246511566,"uuid":"501690627","full_name":"leancodepl/flutter-phone-state","owner":"leancodepl","description":null,"archived":false,"fork":false,"pushed_at":"2024-07-30T07:12:55.000Z","size":97,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-14T18:43:23.304Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/leancodepl.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-06-09T14:38:50.000Z","updated_at":"2024-09-19T07:06:45.000Z","dependencies_parsed_at":"2024-11-14T21:28:55.831Z","dependency_job_id":"4239d89d-6211-4435-811e-d3a839d0502d","html_url":"https://github.com/leancodepl/flutter-phone-state","commit_stats":null,"previous_names":["leancodepl/flutter-phone-state"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leancodepl%2Fflutter-phone-state","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leancodepl%2Fflutter-phone-state/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leancodepl%2Fflutter-phone-state/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leancodepl%2Fflutter-phone-state/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/leancodepl","download_url":"https://codeload.github.com/leancodepl/flutter-phone-state/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241867730,"owners_count":20033816,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-14T21:24:35.668Z","updated_at":"2025-10-20T10:35:00.470Z","avatar_url":"https://github.com/leancodepl.png","language":"Dart","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Flutter Phone State Plugin\n\n[![pub package](https://img.shields.io/pub/v/flutter_phone_state.svg)](https://pub.dartlang.org/packages/flutter_phone_state)\n[![Coverage Status](https://coveralls.io/repos/github/SunnyApp/flutter_phone_state/badge.svg?branch=master)](https://coveralls.io/github/SunnyApp/flutter_phone_state?branch=master)\n\n\nA Flutter plugin that makes it easier to make and track phone calls.  The core features are:\n\n1.  Initiate a phone call in 1 line of code\n2.  `await` any in-flight phone call\n3.  Watch all phone-related events for a single call, or all calls\n4.  Track duration of calls, errors, and cancellations\n\n## Getting Started\n\nInstall the plugin:\n\n```yaml\nflutter_phone_state: ^0.5.8\n```\n\n## Before you start\n\nBoth Android and iOS put restrictions on accessing phone call data. This plugin makes a \nbest-effort attempt to track the complete lifecycle of a phone call, but it's not perfect and has its limitations.  Read the \n`Limitations` section below for more info.\n\n## Initiate a call\n\nIt's recommended that you initiate calls from your app when possible.  This gives you the \nbest chance at tracking the call.\n```dart\n// note: this plugin will remove all non-numeric characters from the phone number\nfinal phoneCall = FlutterPhoneState.startPhoneCall(\"480-555-1234\"); \n```\n\nA `PhoneCall` object is the source of truth for the call\n\n```dart\nshowCallInfo(PhoneCall phoneCall) {\n    print(phoneCall.status); // ringing, dialing, cancelled, error, connecting, connected, timedOut, disconnected \n    print(phoneCall.isComplete); // Whether the call is complete\n    print(phoneCall.events); // A list of call events related to this specific call\n}\n```\n\nYou can read the `PhoneCall.events` as a stream, and when the call is completed, the plugin will \nclose the stream gracefully.  The plugin watches all in-flight calls, and will force any \ncall to timeout eventually.\n```dart\nwatchEvents(PhoneCall phoneCall) {\n  phoneCall.eventStream.forEach((PhoneCallEvent event) {\n    print(\"Event $event\");\n  });\n  print(\"Call is complete\");\n}\n```\n\nAlternatively, you can just wait for the call to complete\n```dart\nwaitForCompletion(PhoneCall phoneCall) async {\n  await phoneCall.done;\n  print(\"Call is completed\");\n}\n```\n\n## Accessing in-flight calls\n\nIn-flight calls can be accessed like this:\n```dart\nfinal activeCalls = FutterPhoneState.activeCalls;\n```\nNote that `activeCalls` is an immutable copy of the calls at the moment you called `activeCalls`.  It \nwon't update automatically.\n\n## Watching all events\n\nInstead of focusing on a single call, you can watch all the events. We recommend using  \n`FlutterPhoneState.phoneCallEventStream` - because this `Stream` incorporates our own \ntracking logic, call timeouts, failures, etc.\n\n```dart\n_watchAllPhoneCallEvents() {\n  FlutterPhoneState.phoneCallEvents.forEach((PhoneCallEvent event) {\n    final phoneCall = event.call;\n    print(\"Got an event $event\");\n  });\n  print(\"That loop ^^ won't end\");\n}\n```\n\nIf you want, you can subscribe to the raw underlying events.  Keep in mind that these events are limited.\n\n```dart\n_watchAllRawEvents() {\n  FlutterPhoneState.rawPhoneEvent.forEach((RawPhoneEvent event) {\n    final phoneCall = event.call;\n    print(\"Got an event $event\");\n  });\n  print(\"That loop ^^ won't end\");\n}\n```\n\n## Limitations\n\n### Phone Numbers\n\nNeither platform gives us phone numbers with call events.  This is largely why we recommend initiating\nthe call using the plugin, so you can tie it back to the original number.\n\nAnd obviously, this means that you'll never get the phone number from an inbound call.  Sorry!\n\n### Android\n\nAndroid doesn't track nested calls.  So, once the first call is active, if you receive another\ncall, or make another call (by putting the first on hold), the second call will not be tracked\nat all.  \n\nAlso, Android doesn't provide a unique call identifier, so any call events that occur can't be linked \ntogether with a platform-assigned id.\n\n## How does it work?\n\n1.  This plugin registers to `AppLifecycleState` events, and uses those events to determine when \nan outbound call has been placed vs cancelled.\n2.  When possible, the plugin links phone lifecycle events together by the platform-assigned \ncall identifier. (this works on iOS)\n3.  The plugin checks the actual lifecycle states - for example, if one call is `connected` and \nthe plugin gets a `dialing` event, it's clear that the `dialing` event must be for a new/different call, and\ntherefore begins tracking it as a new call.  \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleancodepl%2Fflutter-phone-state","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleancodepl%2Fflutter-phone-state","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleancodepl%2Fflutter-phone-state/lists"}