73 lines
1.6 KiB
Dart
73 lines
1.6 KiB
Dart
|
|
import 'package:satu/core/utils/utils_parse.dart';
|
|
|
|
class PrinterConst {
|
|
PrinterConst();
|
|
static const String paperSize58mm = '58mm';
|
|
static const String paperSize80mm = '80mm';
|
|
static const String encodingCP866 = 'CP866';
|
|
static const String encodingCP1251 = 'Windows-1251';
|
|
static const String encodingBigEncoding = 'BigEncoding';
|
|
}
|
|
|
|
class PrinterSetting {
|
|
|
|
PrinterSetting({
|
|
this.device,
|
|
this.encoding = PrinterConst.encodingCP866,
|
|
this.paperSize = PrinterConst.paperSize58mm,
|
|
});
|
|
|
|
PrinterDevice? device;
|
|
String? encoding ;
|
|
String? paperSize ;
|
|
|
|
dynamic toMap() {
|
|
return {
|
|
'device': device != null ? device!.toMap() : null,
|
|
'encoding': encoding,
|
|
'paperSize': paperSize,
|
|
};
|
|
}
|
|
|
|
factory PrinterSetting.fromMap(dynamic map) {
|
|
return PrinterSetting(
|
|
device: map['device']!=null ? PrinterDevice.fromMap(map['device']) : null,
|
|
encoding: cast<String>(map['encoding']),
|
|
paperSize: cast<String>(map['paperSize']),
|
|
);
|
|
}
|
|
|
|
}
|
|
|
|
class PrinterDevice {
|
|
String? name;
|
|
String? address;
|
|
int? type = 0;
|
|
bool? connected = false;
|
|
|
|
PrinterDevice({
|
|
this.name,
|
|
this.address,
|
|
this.type,
|
|
this.connected,
|
|
});
|
|
|
|
dynamic toMap() {
|
|
return {
|
|
'name': name,
|
|
'address': address,
|
|
'type': type,
|
|
'connected': connected,
|
|
};
|
|
}
|
|
|
|
factory PrinterDevice.fromMap(dynamic map) {
|
|
return PrinterDevice(
|
|
name: cast<String>(map['name']),
|
|
address: cast<String>(map['address']),
|
|
type: cast<int>(map['type']),
|
|
connected: cast<bool>(map['connected']),
|
|
);
|
|
}
|
|
} |