bluetooth_power_state.dart 821 B

1234567891011121314151617181920212223242526272829303132
  1. /// Bluetooth adapter power state reported by the native bridge.
  2. ///
  3. /// `turningOn` and `turningOff` are deliberately separate from `on`/`off` so
  4. /// the Settings card never lists bonded devices while the stack is still
  5. /// initializing.
  6. enum BluetoothPowerState {
  7. unknown,
  8. unavailable,
  9. off,
  10. turningOn,
  11. on,
  12. turningOff;
  13. static BluetoothPowerState fromWire(Object? value) {
  14. return switch (value) {
  15. 'on' => on,
  16. 'off' => off,
  17. 'turning_on' => turningOn,
  18. 'turning_off' => turningOff,
  19. 'unavailable' => unavailable,
  20. _ => unknown,
  21. };
  22. }
  23. bool get isOn => this == BluetoothPowerState.on;
  24. bool get isOff => this == BluetoothPowerState.off;
  25. bool get isTransitioning =>
  26. this == BluetoothPowerState.turningOn ||
  27. this == BluetoothPowerState.turningOff;
  28. }