CallDetector class
CallDetector is a singleton class designed for detecting and monitoring phone call status on the platform.
It provides a single access point to a stream of call state events, along with methods to retrieve the current call status.
CallDetector encapsulates the logic for interacting with
native platforms to obtain call-related information. It uses MethodChannel
to invoke native methods, and EventChannel to receive streaming updates
about the call status. This class is implemented as a singleton to ensure
only one instance of the detector exists throughout the app’s lifecycle,
preventing resource duplication and conflicts.
Example usage:
final callDetector = CallDetector();
callDetector.callDetectStream.listen((isCalling) {
if (isCalling) {
print('Active call detected!');
} else {
print('Call ended or not active.');
}
});
Constructors
- CallDetector()
-
CallDetector is a singleton class designed for detecting and monitoring
phone call status on the platform.
factory
Properties
-
callDetectStream
→ Stream<
bool> -
no setter
- channelService ↔ CallChannelService
-
getter/setter pairinherited
-
controller
↔ StreamController<
bool> ? -
getter/setter pairinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- hasListeners → bool
-
Indicates whether there are active listeners on the call detection stream.
no setter
- isStreamActive → bool
-
Indicates whether the call detection stream is currently active.
no setter
- lastCallStatus → bool
-
Returns the most recent known call status.
no setter
- lastValue ↔ bool?
-
getter/setter pairinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
subscription
↔ StreamSubscription<
bool> ? -
getter/setter pairinherited
Methods
-
getCurrentCallStatus(
) → Future< bool> - Asynchronously fetches the current call status from the platform.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited