TargetPrinter.fromJson constructor
TargetPrinter.fromJson(
- Map<String, dynamic> j
)
Implementation
factory TargetPrinter.fromJson(Map<String, dynamic> j) => TargetPrinter(
name: (j['name'] as String?) ?? '',
host: (j['host'] as String?) ?? '',
transport: (j['transport'] as String?)?.isNotEmpty == true ? j['transport'] as String : PrinterTransport.network,
isDefault: j['default'] == true,
language: (j['language'] as String?)?.isNotEmpty == true ? j['language'] as String : PrinterLanguage.escpos,
widthDots: (j['width_dots'] as num?)?.toInt() ?? 384,
paperWidthMm: (j['paper_width_mm'] as num?)?.toInt() ?? 0,
paperHeightMm: (j['paper_height_mm'] as num?)?.toInt() ?? 0,
dpi: (j['dpi'] as num?)?.toInt() ?? 203,
compress: j['compress'] == true,
plGapMm: (j['pl_gap_mm'] as num?)?.toInt() ?? 2,
plDensity: (j['pl_density'] as num?)?.toInt() ?? 8,
plDirection: (j['pl_direction'] as num?)?.toInt() ?? 0,
xpCut: (j['xp_cut'] as String?)?.isNotEmpty == true ? j['xp_cut'] as String : 'partial',
xpDensity: (j['xp_density'] as num?)?.toInt() ?? 0,
);