stopNotifications method

Future<void> stopNotifications()

Request the BluetoothCharacteristic to stop notifying. This means that you will not long get notifications of changes to the value.

  • May throw StateError if the characteristic is null.

See: startNotifications, isNotifying, value and lastValue.

Implementation

Future<void> stopNotifications() async {
  try {
    await _characteristic.stopNotifications();
    _isNotifying = false;
  } catch (e) {
    final error = e.toString().trim();
    if (error.startsWith("InvalidStateError")) {
      throw StateError("Characteristic is null");
    }
    rethrow;
  }
}