stream property

Stream<PhoneState> stream
final

This variable allows you to have a stream of the system phone state change

Implementation

static final Stream<PhoneState> stream =
    _eventChannel.receiveBroadcastStream().distinct().map(
          (dynamic event) => PhoneState._(
            status: PhoneStateStatus.values.firstWhereOrNull(
                  (element) => element.name == event['status'] as String,
                ) ??
                PhoneStateStatus.NOTHING,
            number: event['phoneNumber'],
            duration: event['callDuration'] != 0
                ? Duration(seconds: event['callDuration'])
                : null,
          ),
        );