setSettings method

Future setSettings(
  1. Command setting,
  2. dynamic values
)

Implementation

Future<dynamic> setSettings(Command setting, dynamic values) async {
  String command = "";
  switch (setting) {
    case Command.mediaType:
      if (values == MediaType.blackMark) {
        command = '''
        ! U1 setvar "media.type" "label"
        ! U1 setvar "media.sense_mode" "bar"
        ''';
      } else if (values == MediaType.journal) {
        command = '''
        ! U1 setvar "media.type" "journal"
        ''';
      } else if (values == MediaType.label) {
        command = '''
        ! U1 setvar "media.type" "label"
         ! U1 setvar "media.sense_mode" "gap"
        ''';
      }

      break;
    case Command.calibrate:
      command = '''~jc^xa^jus^xz''';
      break;
    case Command.darkness:
      command = '''! U1 setvar "print.tone" "$values"''';
      break;
  }

  if (setting == Command.calibrate) {
    command = '''~jc^xa^jus^xz''';
  }

    log("Setting => $command");
    status = PrinterStatus.printing;
    notifier(this);
    await Future.delayed(const Duration(milliseconds: 300));
    await channel.invokeMethod("printData", {"data": command});
    status = PrinterStatus.ready;
    notifier(this);

}