updatePrinterStatus method

void updatePrinterStatus(
  1. String status,
  2. String color,
  3. String? selectedAddress
)

Implementation

void updatePrinterStatus(
    String status, String color, String? selectedAddress) {
  if (selectedAddress != null) {
    Color newColor = Colors.grey.withOpacity(0.6);
    switch (color) {
      case 'R':
        newColor = Colors.red;
        break;
      case 'G':
        newColor = Colors.green;
        break;
      default:
        newColor = Colors.grey.withOpacity(0.6);
        break;
    }
    final int index =
        _printers.indexWhere((element) => element.address == selectedAddress);
    _printers[index] =
        _printers[index].copyWith(status: status, color: newColor);
    notifyListeners();
  }
}