diff --git a/assets/image/ic_appbar_back.svg b/assets/image/ic_appbar_back.svg
new file mode 100644
index 0000000..3784280
--- /dev/null
+++ b/assets/image/ic_appbar_back.svg
@@ -0,0 +1,4 @@
+
diff --git a/assets/image/ic_bluetooth.svg b/assets/image/ic_bluetooth.svg
new file mode 100644
index 0000000..dd812d8
--- /dev/null
+++ b/assets/image/ic_bluetooth.svg
@@ -0,0 +1,5 @@
+
diff --git a/assets/image/ic_printer_bold.svg b/assets/image/ic_printer_bold.svg
new file mode 100644
index 0000000..1330c24
--- /dev/null
+++ b/assets/image/ic_printer_bold.svg
@@ -0,0 +1,5 @@
+
diff --git a/assets/image/ic_printer_bulk.svg b/assets/image/ic_printer_bulk.svg
new file mode 100644
index 0000000..64ad73e
--- /dev/null
+++ b/assets/image/ic_printer_bulk.svg
@@ -0,0 +1,7 @@
+
diff --git a/example/lib/main.dart b/example/lib/main.dart
index 231f897..768bf23 100644
--- a/example/lib/main.dart
+++ b/example/lib/main.dart
@@ -3,6 +3,7 @@ import 'dart:developer';
import 'package:flutter/material.dart';
import 'package:max_print_plus/max_print_plus.dart';
import 'package:max_print_plus/print/max_print.dart';
+import 'package:max_print_plus/print/max_print_bt.dart';
void main() {
runApp(const MyApp());
@@ -54,16 +55,21 @@ class _MyHomePageState extends State {
child: Text('Click me')),
ElevatedButton(
onPressed: () {
- _printReceiveTest(true);
+ _printReceiveTest(false);
},
child: Text('Print page mode')),
+ ElevatedButton(
+ onPressed: () {
+ _printReceiveTest(true);
+ },
+ child: Text('Print page single mode')),
],
),
),
));
}
- Future _printReceiveTest(bool isPage) async {
+ Future _printReceiveTest(bool isSinglePage) async {
List bytes = [];
// Xprinter XP-N160I
@@ -259,13 +265,24 @@ class _MyHomePageState extends State {
bytes += generator.text('TERIMA KASIH',
styles: const PosStyles(align: PosAlign.center));
- Navigator.push(
- context,
- MaterialPageRoute(
- builder: (context) => MaxPrint(
- bytes: bytes,
- generator: generator,
- )));
+ if (isSinglePage) {
+ Navigator.push(
+ context,
+ MaterialPageRoute(
+ builder: (context) => MaxPrintBt(
+ bytes: bytes,
+ generator: generator,
+ onSuccess: (p0) {},
+ )));
+ } else {
+ Navigator.push(
+ context,
+ MaterialPageRoute(
+ builder: (context) => MaxPrint(
+ bytes: bytes,
+ generator: generator,
+ )));
+ }
}
// _showPrintDialog(List bytes, Generator generator) {
diff --git a/lib/max_print copy.dart b/lib/max_print copy.dart
deleted file mode 100644
index 54fc7e0..0000000
--- a/lib/max_print copy.dart
+++ /dev/null
@@ -1,448 +0,0 @@
-// library max_print_dialog;
-
-// import 'dart:async';
-// import 'dart:developer';
-// import 'dart:io';
-
-// import 'package:flutter/material.dart';
-// import 'package:thermal_printer/esc_pos_utils_platform/esc_pos_utils_platform.dart';
-// import 'package:thermal_printer/thermal_printer.dart';
-// import 'my_button.dart';
-// import 'printer_devices.dart';
-
-// class MaxPrintPage extends StatefulWidget {
-// Function()? onSuccess;
-// PreferredSizeWidget? appBar;
-// String? title, description;
-// Color? btnOkTextColor,
-// btnOkBorderColor,
-// btnOkColor,
-// btnCancelTextColor,
-// btnCancelBorderColor,
-// btnCancelColor;
-// double? btnRadius, btnHeight, btnWidth;
-// List bytes;
-// Generator generator;
-// Function()? onCancelTap;
-
-// MaxPrintPage(
-// {Key? key,
-// required this.appBar,
-// required this.bytes,
-// required this.generator,
-// this.onSuccess,
-// this.description,
-// this.title,
-// this.btnOkBorderColor,
-// this.btnOkColor,
-// this.btnRadius,
-// this.btnOkTextColor,
-// this.btnCancelBorderColor,
-// this.btnCancelColor,
-// this.btnCancelTextColor,
-// this.btnHeight,
-// this.btnWidth,
-// this.onCancelTap})
-// : super(key: key);
-
-// @override
-// _MaxPrintPageState createState() => _MaxPrintPageState();
-// }
-
-// class _MaxPrintPageState extends State {
-// bool isLoadingButton = false;
-
-// // Thermal
-// var defaultPrinterType = PrinterType.bluetooth;
-// var _isBle = false;
-// var _reconnect = false;
-// var _isConnected = false;
-// var printerManager = PrinterManager.instance;
-// var devices = [];
-// StreamSubscription? _subscription;
-// StreamSubscription? _subscriptionBtStatus;
-// StreamSubscription? _subscriptionUsbStatus;
-// StreamSubscription? _subscriptionTCPStatus;
-// BTStatus _currentStatus = BTStatus.none;
-// // ignore: unused_field
-// TCPStatus _currentTCPStatus = TCPStatus.none;
-// // _currentUsbStatus is only supports on Android
-// // ignore: unused_field
-// USBStatus _currentUsbStatus = USBStatus.none;
-// List? pendingTask;
-// final String _ipAddress = '';
-// String _port = '9100';
-// final _ipController = TextEditingController();
-// final _portController = TextEditingController();
-// PrinterDevices? selectedPrinter;
-
-// @override
-// void initState() {
-// _initialize();
-// super.initState();
-// }
-
-// @override
-// void dispose() {
-// _subscription?.cancel();
-// _subscriptionBtStatus?.cancel();
-// _subscriptionUsbStatus?.cancel();
-// _subscriptionTCPStatus?.cancel();
-// _portController.dispose();
-// _ipController.dispose();
-// super.dispose();
-// }
-
-// @override
-// Widget build(BuildContext context) {
-// return Scaffold(
-// backgroundColor: const Color(0xFFFAFAFA),
-// bottomNavigationBar: Padding(
-// padding: const EdgeInsets.all(16),
-// child: Row(
-// mainAxisSize: MainAxisSize.min,
-// children: [
-// Flexible(
-// child: MyButton(
-// width: double.infinity,
-// text: 'Tutup',
-// textColor: widget.btnCancelTextColor ?? Colors.black,
-// borderColor: widget.btnCancelBorderColor ?? Colors.amber,
-// color: widget.btnCancelColor ?? Colors.white,
-// press: widget.onCancelTap ??
-// () {
-// Navigator.pop(context);
-// })),
-// const SizedBox(
-// width: 16.0,
-// ),
-// Flexible(
-// child: MyButton(
-// width: double.infinity,
-// textColor: widget.btnOkTextColor,
-// borderColor: widget.btnOkBorderColor,
-// color: widget.btnOkColor,
-// text: 'Cetak',
-// press: () {
-// _printReceiveTest();
-// }))
-// ],
-// ),
-// ),
-// appBar: widget.appBar,
-// body: _buildView(context));
-// }
-
-// _buildView(BuildContext context) {
-// return Padding(
-// padding: const EdgeInsets.all(20.0),
-// child: ListView(
-// shrinkWrap: true,
-// children: [
-// const SizedBox(
-// height: 16.0,
-// ),
-// const Text(
-// 'Daftar perangkat :',
-// style: TextStyle(color: Color(0xFF0E0F0F), fontSize: 16.0),
-// ),
-// const SizedBox(
-// height: 10.0,
-// ),
-// // Row(
-// // children: [
-// // _chipOption(label: 'BT', val: PrinterType.bluetooth),
-// // _chipOption(label: 'IP', val: PrinterType.network),
-// // ],
-// // ),
-// Container(
-// decoration: BoxDecoration(
-// borderRadius: BorderRadius.circular(16.0), color: Colors.white),
-// child: Material(
-// color: Colors.transparent,
-// child: Column(
-// children: devices
-// .map(
-// (device) => ListTile(
-// title: Row(
-// crossAxisAlignment: CrossAxisAlignment.center,
-// children: [
-// Text(
-// '${device.deviceName}',
-// maxLines: 1,
-// style: const TextStyle(
-// fontWeight: FontWeight.w600,
-// fontSize: 16.0),
-// ),
-// const SizedBox(
-// width: 6.0,
-// ),
-// selectedPrinter != null &&
-// ((device.typePrinter ==
-// PrinterType.usb &&
-// Platform.isWindows
-// ? device.deviceName ==
-// selectedPrinter!.deviceName
-// : device.vendorId != null &&
-// selectedPrinter!.vendorId ==
-// device.vendorId) ||
-// (device.address != null &&
-// selectedPrinter!.address ==
-// device.address))
-// ? const Icon(
-// Icons.check_circle,
-// color: Colors.green,
-// size: 16.0,
-// )
-// : const SizedBox()
-// ],
-// ),
-// subtitle: Platform.isAndroid &&
-// defaultPrinterType == PrinterType.usb
-// ? null
-// : Visibility(
-// visible: !Platform.isWindows,
-// child: Text("${device.address}")),
-// onTap: () async {
-// // do something
-// selectDevice(device);
-// _connectDevice();
-// await device.saveToPrefs();
-// },
-// trailing: Material(
-// color: Colors.transparent,
-// child: IconButton(
-// onPressed: selectedPrinter == null ||
-// device.deviceName !=
-// selectedPrinter?.deviceName
-// ? null
-// : () async {
-// _connectDevice();
-// await selectedPrinter!.saveToPrefs();
-// },
-// icon: Image.asset(
-// device.deviceName ==
-// selectedPrinter?.deviceName
-// ? 'assets/ic_connect_on.png'
-// : 'assets/ic_connect_off.png',
-// package: 'max_print_dialog',
-// )),
-// )),
-// )
-// .toList()),
-// ),
-// ),
-// const SizedBox(
-// height: 16.0,
-// ),
-// ],
-// ),
-// );
-// }
-
-// void _scan() {
-// devices.clear();
-// _subscription = printerManager
-// .discovery(type: defaultPrinterType, isBle: _isBle)
-// .listen((device) {
-// devices.add(PrinterDevices(
-// deviceName: device.name,
-// address: device.address,
-// isBle: _isBle,
-// vendorId: device.vendorId,
-// productId: device.productId,
-// typePrinter: defaultPrinterType,
-// ));
-// setState(() {});
-// });
-// }
-
-// _connectDevice() async {
-// _isConnected = false;
-// if (selectedPrinter == null) return;
-// switch (selectedPrinter!.typePrinter) {
-// case PrinterType.usb:
-// await printerManager.connect(
-// type: selectedPrinter!.typePrinter,
-// model: UsbPrinterInput(
-// name: selectedPrinter!.deviceName,
-// productId: selectedPrinter!.productId,
-// vendorId: selectedPrinter!.vendorId));
-// _isConnected = true;
-// break;
-// case PrinterType.bluetooth:
-// await printerManager.connect(
-// type: selectedPrinter!.typePrinter,
-// model: BluetoothPrinterInput(
-// name: selectedPrinter!.deviceName,
-// address: selectedPrinter!.address!,
-// isBle: selectedPrinter!.isBle ?? false,
-// autoConnect: _reconnect));
-// break;
-// case PrinterType.network:
-// await printerManager.connect(
-// type: selectedPrinter!.typePrinter,
-// model: TcpPrinterInput(ipAddress: selectedPrinter!.address!));
-// _isConnected = true;
-// break;
-// default:
-// }
-
-// setState(() {});
-// }
-
-// void selectDevice(PrinterDevices device) async {
-// if (selectedPrinter != null) {
-// if ((device.address != selectedPrinter!.address) ||
-// (device.typePrinter == PrinterType.usb &&
-// selectedPrinter!.vendorId != device.vendorId)) {
-// await PrinterManager.instance
-// .disconnect(type: selectedPrinter!.typePrinter);
-// }
-// }
-
-// selectedPrinter = device;
-// setState(() {});
-// }
-
-// _printReceiveTest() {
-// _printEscPos(widget.bytes, widget.generator);
-
-// widget.onSuccess!();
-// }
-
-// /// print ticket
-// void _printEscPos(List bytes, Generator generator) async {
-// var connectedTCP = false;
-// if (selectedPrinter == null) return;
-// var bluetoothPrinter = selectedPrinter!;
-// switch (bluetoothPrinter.typePrinter) {
-// case PrinterType.usb:
-// bytes += generator.feed(2);
-// bytes += generator.cut();
-// await printerManager.connect(
-// type: bluetoothPrinter.typePrinter,
-// model: UsbPrinterInput(
-// name: bluetoothPrinter.deviceName,
-// productId: bluetoothPrinter.productId,
-// vendorId: bluetoothPrinter.vendorId));
-// pendingTask = null;
-// break;
-// case PrinterType.bluetooth:
-// bytes += generator.cut();
-// await printerManager.connect(
-// type: bluetoothPrinter.typePrinter,
-// model: BluetoothPrinterInput(
-// name: bluetoothPrinter.deviceName,
-// address: bluetoothPrinter.address!,
-// isBle: bluetoothPrinter.isBle ?? false,
-// autoConnect: _reconnect));
-// pendingTask = null;
-// if (Platform.isAndroid) pendingTask = bytes;
-// break;
-// case PrinterType.network:
-// bytes += generator.feed(2);
-// bytes += generator.cut();
-// connectedTCP = await printerManager.connect(
-// type: bluetoothPrinter.typePrinter,
-// model: TcpPrinterInput(ipAddress: bluetoothPrinter.address!));
-// if (!connectedTCP) print(' --- please review your connection ---');
-// break;
-// default:
-// }
-// if (bluetoothPrinter.typePrinter == PrinterType.bluetooth &&
-// Platform.isAndroid) {
-// if (_currentStatus == BTStatus.connected) {
-// printerManager.send(type: bluetoothPrinter.typePrinter, bytes: bytes);
-// pendingTask = null;
-// }
-// } else {
-// printerManager.send(type: bluetoothPrinter.typePrinter, bytes: bytes);
-// }
-// }
-
-// Future _initialize() async {
-// PrinterDevices? printer = await PrinterDevices.getFromPrefs();
-
-// _scan();
-// if (printer != null) {
-// selectDevice(printer);
-// }
-
-// // subscription to listen change status of bluetooth connection
-// _subscriptionBtStatus =
-// PrinterManager.instance.stateBluetooth.listen((status) {
-// log(' ----------------- status bt $status ------------------ ');
-// _currentStatus = status;
-// if (status == BTStatus.connected) {
-// setState(() {
-// _isConnected = true;
-// });
-// }
-// if (status == BTStatus.none) {
-// setState(() {
-// _isConnected = false;
-// });
-// }
-// if (status == BTStatus.connected && pendingTask != null) {
-// if (Platform.isAndroid) {
-// Future.delayed(const Duration(milliseconds: 1000), () {
-// PrinterManager.instance
-// .send(type: PrinterType.bluetooth, bytes: pendingTask!);
-// pendingTask = null;
-// });
-// } else if (Platform.isIOS) {
-// PrinterManager.instance
-// .send(type: PrinterType.bluetooth, bytes: pendingTask!);
-// pendingTask = null;
-// }
-// }
-// });
-// // PrinterManager.instance.stateUSB is only supports on Android
-// _subscriptionUsbStatus = PrinterManager.instance.stateUSB.listen((status) {
-// log(' ----------------- status usb $status ------------------ ');
-// _currentUsbStatus = status;
-// if (Platform.isAndroid) {
-// if (status == USBStatus.connected && pendingTask != null) {
-// Future.delayed(const Duration(milliseconds: 1000), () {
-// PrinterManager.instance
-// .send(type: PrinterType.usb, bytes: pendingTask!);
-// pendingTask = null;
-// });
-// }
-// }
-// });
-
-// // PrinterManager.instance.stateUSB is only supports on Android
-// _subscriptionTCPStatus = PrinterManager.instance.stateTCP.listen((status) {
-// log(' ----------------- status tcp $status ------------------ ');
-// _currentTCPStatus = status;
-// });
-// }
-
-// _chipOption({required String label, required PrinterType val}) {
-// return Row(
-// children: [
-// Radio(
-// value: val,
-// groupValue: defaultPrinterType,
-// onChanged: (v) {
-// setState(() {
-// defaultPrinterType = v!;
-// selectedPrinter = null;
-// _isBle = false;
-// _isConnected = false;
-// _scan();
-// });
-// }),
-// const SizedBox(
-// width: 10.0,
-// ),
-// Text(
-// label,
-// style: const TextStyle(fontSize: 16.0),
-// )
-// ],
-// );
-// }
-// }
diff --git a/lib/print/bluetooth_printer_screen.dart b/lib/print/bluetooth_printer_screen.dart
index cb0a807..6fc55a2 100644
--- a/lib/print/bluetooth_printer_screen.dart
+++ b/lib/print/bluetooth_printer_screen.dart
@@ -1,6 +1,8 @@
import 'dart:typed_data';
import 'package:flutter/material.dart';
import 'package:drago_pos_printer/drago_pos_printer.dart';
+import 'package:flutter_svg/svg.dart';
+import 'package:max_print_plus/widget/my_button.dart';
// import 'package:webcontent_converter/demo.dart';
// import 'package:webcontent_converter/webcontent_converter.dart';
import '../service/service.dart';
@@ -8,9 +10,15 @@ import '../service/service.dart';
class BluetoothPrinterScreen extends StatefulWidget {
List bytes;
EscGenerator generator;
-
- BluetoothPrinterScreen(
- {super.key, required this.bytes, required this.generator});
+ Function(bool)? onSuccess;
+ bool? hideOption;
+ BluetoothPrinterScreen({
+ super.key,
+ required this.bytes,
+ required this.generator,
+ this.onSuccess,
+ this.hideOption = true,
+ });
@override
_BluetoothPrinterScreenState createState() => _BluetoothPrinterScreenState();
@@ -43,41 +51,42 @@ class _BluetoothPrinterScreenState extends State {
@override
Widget build(BuildContext context) {
return Scaffold(
- backgroundColor: Color(0xFFFAFAFA),
+ backgroundColor: const Color(0xFFFAFAFA),
body: ListView(
- padding: EdgeInsets.all(20),
+ padding: const EdgeInsets.all(20),
children: [
- DropdownButtonHideUnderline(
- child: DropdownButtonFormField(
- decoration: InputDecoration(labelText: 'Paper Size'),
- items: paperTypes.map((item) {
- return DropdownMenuItem(
- value: item,
- child: Text(item),
- );
- }).toList(),
- onChanged: (String? selected) async {
- showCustom = false;
- if (selected != null) {
- if (selected == "58mm") {
- paperWidth = PaperSizeWidth.mm58;
- charPerLine = PaperSizeMaxPerLine.mm58;
- } else if (selected == "80mmOld") {
- paperWidth = PaperSizeWidth.mm80_Old;
- charPerLine = PaperSizeMaxPerLine.mm80_Old;
- } else if (selected == "80mm") {
- paperWidth = PaperSizeWidth.mm80;
- charPerLine = PaperSizeMaxPerLine.mm80;
- } else if (selected == "Custom") {
- paperWidth = PaperSizeWidth.mm80;
- charPerLine = PaperSizeMaxPerLine.mm80;
- showCustom = true;
+ if (!widget.hideOption!)
+ DropdownButtonHideUnderline(
+ child: DropdownButtonFormField(
+ decoration: const InputDecoration(labelText: 'Paper Size'),
+ items: paperTypes.map((item) {
+ return DropdownMenuItem(
+ value: item,
+ child: Text(item),
+ );
+ }).toList(),
+ onChanged: (String? selected) async {
+ showCustom = false;
+ if (selected != null) {
+ if (selected == "58mm") {
+ paperWidth = PaperSizeWidth.mm58;
+ charPerLine = PaperSizeMaxPerLine.mm58;
+ } else if (selected == "80mmOld") {
+ paperWidth = PaperSizeWidth.mm80_Old;
+ charPerLine = PaperSizeMaxPerLine.mm80_Old;
+ } else if (selected == "80mm") {
+ paperWidth = PaperSizeWidth.mm80;
+ charPerLine = PaperSizeMaxPerLine.mm80;
+ } else if (selected == "Custom") {
+ paperWidth = PaperSizeWidth.mm80;
+ charPerLine = PaperSizeMaxPerLine.mm80;
+ showCustom = true;
+ }
+ setState(() {});
}
- setState(() {});
- }
- },
+ },
+ ),
),
- ),
if (showCustom)
Row(
children: [
@@ -87,41 +96,92 @@ class _BluetoothPrinterScreenState extends State {
onChanged: (val) {
if (val.isNotEmpty) {
paperWidth = int.parse(val);
- } else
+ } else {
paperWidth = 0;
+ }
},
)),
- SizedBox(width: 20),
+ const SizedBox(width: 20),
Expanded(
child: TextFormField(
initialValue: charPerLine.toString(),
onChanged: (val) {
if (val.isNotEmpty) {
charPerLine = int.parse(val);
- } else
+ } else {
charPerLine = 0;
+ }
},
))
],
),
- SizedBox(height: 10),
+ if (!widget.hideOption!) const SizedBox(height: 10),
+ if (_printers.isEmpty)
+ Container(
+ padding: const EdgeInsets.only(top: 100),
+ child: Column(
+ children: [
+ SvgPicture.asset(
+ 'assets/image/ic_printer_bulk.svg',
+ width: 200,
+ height: 200,
+ package: 'max_print_plus',
+ color: const Color.fromARGB(255, 207, 216, 220),
+ ),
+ const SizedBox(
+ height: 16,
+ ),
+ const Text(
+ 'Bluetooth Kosong',
+ style: TextStyle(
+ fontWeight: FontWeight.w600,
+ fontSize: 20,
+ color: Color.fromARGB(255, 186, 197, 202),
+ ),
+ )
+ ],
+ ),
+ ),
..._printers
.map((printer) => ListTile(
- title: Text("${printer.name}"),
- subtitle: Text("${printer.address}"),
- leading: Icon(Icons.bluetooth),
+ title: Text(
+ "${printer.name}",
+ style: const TextStyle(
+ color: Colors.black,
+ fontWeight: FontWeight.w600,
+ fontSize: 15),
+ ),
+ selectedColor: Colors.green,
+ subtitle: Text("${printer.address}",
+ style: const TextStyle(color: Colors.black)),
+ leading: SvgPicture.asset(
+ 'assets/image/ic_bluetooth.svg',
+ width: 30,
+ height: 30,
+ package: 'max_print_plus',
+ color: printer.connected ? Colors.green : Colors.grey,
+ ),
onTap: () => _connect(printer),
trailing: printer.connected
? Wrap(
children: [
IconButton(
- tooltip: 'ESC POS Command',
- onPressed: () => _startPrinter(1, printer),
- icon: Icon(Icons.print)),
- IconButton(
- tooltip: 'Html Print',
- onPressed: () => _startPrinter(3, printer),
- icon: Icon(Icons.image)),
+ tooltip: 'ESC POS Command',
+ onPressed: () => _startPrinter(1, printer),
+ icon: SvgPicture.asset(
+ 'assets/image/ic_printer_bold.svg',
+ width: 28,
+ height: 28,
+ package: 'max_print_plus',
+ color: printer.connected
+ ? Colors.green
+ : Colors.grey,
+ ),
+ ),
+ // IconButton(
+ // tooltip: 'Html Print',
+ // onPressed: () => _startPrinter(3, printer),
+ // icon: const Icon(Icons.image)),
],
)
: null,
@@ -130,9 +190,14 @@ class _BluetoothPrinterScreenState extends State {
.toList(),
],
),
- floatingActionButton: FloatingActionButton(
- child: _isLoading ? Icon(Icons.stop) : Icon(Icons.play_arrow),
- onPressed: _isLoading ? null : _scan,
+ bottomNavigationBar: Container(
+ padding: const EdgeInsets.all(16),
+ child: MyButton(
+ text: 'Refresh',
+ textColor: Colors.black,
+ press: _isLoading ? null : _scan,
+ width: double.infinity,
+ ),
),
);
}
@@ -165,37 +230,21 @@ class _BluetoothPrinterScreenState extends State {
var profile = await CapabilityProfile.load();
await _connect(printer);
- late List data;
- if (byteType == 1) {
- data = await ESCPrinterService(null).getSamplePosBytes(
- paperSizeWidthMM: paperWidth,
- maxPerLine: charPerLine,
- profile: profile,
- bytesData: widget.bytes,
- );
- } else if (byteType == 2) {
- data = await ESCPrinterService(null).getPdfBytes(
- paperSizeWidthMM: paperWidth,
- maxPerLine: charPerLine,
- profile: profile);
- } else if (byteType == 3) {
- // final content = Demo.getShortReceiptContent();
-
- // Uint8List? htmlBytes = await WebcontentConverter.contentToImage(
- // content: content,
- // executablePath: WebViewHelper.executablePath(),
- // );
-
- // var service = ESCPrinterService(htmlBytes);
- // data = await service.getBytes(
- // paperSizeWidthMM: paperWidth,
- // maxPerLine: charPerLine,
- // profile: profile);
- }
+ // late List data;
+ // if (byteType == 1) {
+ List data = await ESCPrinterService(null).getSamplePosBytes(
+ paperSizeWidthMM: paperWidth,
+ maxPerLine: charPerLine,
+ profile: profile,
+ bytesData: widget.bytes,
+ );
if (_manager != null) {
if (!await _manager!.checkConnected()) await _manager!.connect();
_manager!.writeBytes(data, isDisconnect: true);
}
+
+ // widget.onSuccess!(true);
+ Navigator.pop(context, true);
}
}
diff --git a/lib/print/max_print_bt.dart b/lib/print/max_print_bt.dart
new file mode 100644
index 0000000..660a610
--- /dev/null
+++ b/lib/print/max_print_bt.dart
@@ -0,0 +1,62 @@
+import 'package:drago_pos_printer/utils/esc_pos/generator.dart';
+import 'package:flutter/material.dart';
+import 'package:flutter_svg/svg.dart';
+import 'package:max_print_plus/print/bluetooth_printer_screen.dart';
+
+enum HistoryTabData { reservation, dinein, waitinglist, pickup, delivery }
+
+class MaxPrintBt extends StatefulWidget {
+ List bytes;
+ EscGenerator generator;
+ Function(bool)? onSuccess;
+ bool? hideOption;
+ MaxPrintBt(
+ {Key? key,
+ required this.bytes,
+ required this.generator,
+ required this.onSuccess,
+ this.hideOption = true})
+ : super(key: key);
+
+ @override
+ State createState() => _MaxPrintBtState();
+}
+
+class _MaxPrintBtState extends State with TickerProviderStateMixin {
+ String? uid;
+ bool? isLogin;
+ @override
+ void initState() {
+ super.initState();
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ return Scaffold(
+ backgroundColor: const Color(0xFFFAFAFA),
+ appBar: AppBar(
+ leading: IconButton(
+ onPressed: () {
+ Navigator.of(context).pop();
+ },
+ icon: SvgPicture.asset(
+ 'assets/image/ic_appbar_back.svg',
+ width: 30,
+ height: 30,
+ package: 'max_print_plus',
+ )),
+ backgroundColor: const Color(0xFFFAFAFA),
+ centerTitle: true,
+ title: const Text(
+ 'Cetak',
+ style: TextStyle(
+ fontWeight: FontWeight.bold,
+ // letterSpacing: 2.0,
+ fontSize: 16),
+ ),
+ ),
+ body: BluetoothPrinterScreen(
+ bytes: widget.bytes, generator: widget.generator),
+ );
+ }
+}
diff --git a/lib/my_button.dart b/lib/widget/my_button.dart
similarity index 62%
rename from lib/my_button.dart
rename to lib/widget/my_button.dart
index c5b7766..f780c2d 100644
--- a/lib/my_button.dart
+++ b/lib/widget/my_button.dart
@@ -34,28 +34,28 @@ class MyButton extends StatelessWidget {
child: ElevatedButton(
onPressed: press,
style: ButtonStyle(
- elevation: MaterialStateProperty.all(0),
- padding: MaterialStateProperty.all(
+ elevation: WidgetStateProperty.all(0),
+ padding: WidgetStateProperty.all(
padding ?? const EdgeInsets.all(16.0)),
- backgroundColor: MaterialStateProperty.resolveWith(
- (Set states) {
- if (states.contains(MaterialState.pressed)) {
- return Color(0xFFDCDEE0);
- } else if (states.contains(MaterialState.disabled)) {
- return Color(0xFFF2F2F5);
- } else if (states.contains(MaterialState.focused)) {
- return Color(0xFFFFC700);
+ backgroundColor: WidgetStateProperty.resolveWith(
+ (Set states) {
+ if (states.contains(WidgetState.pressed)) {
+ return const Color(0xFFDCDEE0);
+ } else if (states.contains(WidgetState.disabled)) {
+ return const Color(0xFFF2F2F5);
+ } else if (states.contains(WidgetState.focused)) {
+ return const Color(0xFFFFC700);
}
return color ??
- Color(0xFFFFC700); // Use the component's default.
+ const Color(0xFFFFC700); // Use the component's default.
},
),
- textStyle: MaterialStateProperty.all(
- TextStyle(color: textColor ?? Color(0xFF242632))),
- shape: MaterialStateProperty.resolveWith(
+ textStyle: WidgetStateProperty.all(
+ TextStyle(color: textColor ?? const Color(0xFF242632))),
+ shape: WidgetStateProperty.resolveWith(
(states) {
return RoundedRectangleBorder(
- side: !(states.contains(MaterialState.pressed))
+ side: !(states.contains(WidgetState.pressed))
? BorderSide(color: borderColor ?? Colors.transparent)
: const BorderSide(color: Colors.transparent),
borderRadius:
diff --git a/pubspec.yaml b/pubspec.yaml
index d0afb4f..96ca2f1 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -46,7 +46,8 @@ flutter:
pluginClass: MaxPrintPlusPlugin
ios:
pluginClass: MaxPrintPlusPlugin
-
+ assets:
+ - assets/image/
# To add assets to your plugin package, add an assets section, like this:
# assets:
# - images/a_dot_burr.jpeg