Printer class

Optimized printer model with better data validation and serialization

Inheritance
Available extensions

Constructors

Printer({String? address, String? name, ConnectionType? connectionType, bool? isConnected, String? vendorId, String? productId, String? deviceUri, String? queueName, List<String> services = const [], Map<String, Uint8List> serviceData = const {}, List<ManufacturerData> manufacturerDataList = const []})
Printer.fromJson(Map<String, dynamic> json)
Create Printer from JSON with validation
factory

Properties

address → String?
final
connectionState → Future<BleConnectionState>
Returns connection state of the device. All platforms will return Connected/Disconnected states. Android and Apple can also return Connecting/Disconnecting states.
no setterinherited
connectionStream → Stream<bool>

Available on BleDevice, provided by the BleDeviceExtension extension

A stream of bool that emits connection status changes for the device.
no setter
connectionType → ConnectionType?
final
connectionTypeString → String
Get human-readable connection type string
no setter
deviceId ↔ String
getter/setter pairinherited
deviceUri → String?
Native print queue destination URI, such as usb:// or dnssd://. A Bonjour URI is not an IP address for raw TCP printing.
final
hashCode → int
The hash code for this object.
no setterinherited
hasValidConnectionData → bool
Check if printer has valid connection data
no setter
isConnected → bool?
final
isConnected → Future<bool>

Available on BleDevice, provided by the BleDeviceExtension extension

Checks if the device is currently connected.
no setter
isSystemDevice ↔ bool?
getter/setter pairinherited
isSystemPrinter → bool
no setter
manufacturerData → Uint8List?
no setterinherited
manufacturerDataList ↔ List<ManufacturerData>
getter/setter pairinherited
name ↔ String?
finalgetter/setter pairinherited-setteroverride-getter
paired ↔ bool?
getter/setter pairinherited
pairingStateStream → Stream<bool>

Available on BleDevice, provided by the BleDeviceExtension extension

A stream of bool that emits pairing status changes for the device.
no setter
productId → String?
final
queueName → String?
macOS system queue ID. These printers use the native printing backend regardless of their USB, network, or unknown connection type.
final
rawName ↔ String?
getter/setter pairinherited
receivesAdvertisements → bool
On web, it returns true if the web browser supports receiving advertisements from this device. The rest of the platforms will always return true.
no setterinherited
rssi ↔ int?
getter/setter pairinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
serviceData ↔ Map<String, Uint8List>
getter/setter pairinherited
services ↔ List<String>
List of services advertised by the device.
getter/setter pairinherited
timestamp ↔ int?
getter/setter pairinherited
timestampDateTime → DateTime?
no setterinherited
timestampMicroseconds ↔ int?
getter/setter pairinherited
timestampMicrosecondsDateTime → DateTime?
no setterinherited
uniqueId → String
Generate unique identifier for the printer
no setter
vendorId → String?
final

Methods

connect({bool autoConnect = false, Duration? timeout, ConnectionPlatformConfig? platformConfig}) → Future<void>

Available on BleDevice, provided by the BleDeviceExtension extension

Connects to the device. autoConnect enables automatic reconnection when the device becomes available. platformConfig sets platform specific connection options.
copyWith({String? address, String? name, ConnectionType? connectionType, bool? isConnected, String? vendorId, String? productId, String? deviceUri, String? queueName, List<String>? services, Map<String, Uint8List>? serviceData, List<ManufacturerData>? manufacturerDataList}) → Printer
Create a copy with updated fields
disconnect({Duration? timeout, String? queueId}) → Future<void>

Available on BleDevice, provided by the BleDeviceExtension extension

Disconnects from the device.
discoverServices({Duration? timeout, bool withDescriptors = false, String? queueId}) → Future<List<BleService>>

Available on BleDevice, provided by the BleDeviceExtension extension

Discovers the services offered by the device.
getCharacteristic(String characteristic, {required String service, bool preferCached = true, Duration? timeout, String? queueId}) → Future<BleCharacteristic>

Available on BleDevice, provided by the BleDeviceExtension extension

Retrieves a specific characteristic from a service.
getService(String service, {bool preferCached = true, Duration? timeout, String? queueId}) → Future<BleService>

Available on BleDevice, provided by the BleDeviceExtension extension

Retrieves a specific service.
isPaired({BleCommand? pairingCommand, Duration? timeout, String? queueId}) → Future<bool?>

Available on BleDevice, provided by the BleDeviceExtension extension

Check if a device is paired.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
pair({BleCommand? pairingCommand, Duration? timeout, String? queueId}) → Future<void>

Available on BleDevice, provided by the BleDeviceExtension extension

Pair a device.
readRssi() → Future<int>
Read the RSSI value of this connected device.
inherited
requestMtu(int expectedMtu, {String? queueId}) → Future<int>

Available on BleDevice, provided by the BleDeviceExtension extension

Requests an MTU (Maximum Transmission Unit) value for the connection.
toJson() → Map<String, dynamic>
Convert to JSON with proper formatting
toString() → String
A string representation of this object.
override
unpair({Duration? timeout, String? queueId}) → Future<void>

Available on BleDevice, provided by the BleDeviceExtension extension

Unpair a device.

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

connectionTypeFromDeviceUri(String? deviceUri) → ConnectionType?
Classify a queue's device URI, not the local CUPS server's queue URL. Unknown schemes (including classic Bluetooth) are not assumed to be BLE.
mergeAdvertisementData({required Printer previous, required Printer incoming}) → Printer
Carry previous's advertisement data over to incoming when incoming has none of its own.