blue_print_pos
blue_print_pos copied to clipboard
Still Getting Small
Ive tried your code and its is printing fine, for image, Qr code, but when it comes to text the size of the text is smaller regarless the PaperSize.mm.XX used.
Printer used are POS models:
- T1N
- Q1 when using provided sdk or package like (blue_thermal_printer: ^1.2.0) text prints fine,
Ive tested all the paper size but no sucess
here the full code to replicate
`
import 'package:blue_print_pos/blue_print_pos.dart';
import 'package:blue_print_pos/models/models.dart';
import 'package:blue_print_pos/receipt/receipt.dart';
import 'package:esc_pos_utils_plus/esc_pos_utils.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
final BluePrintPos _bluePrintPos = BluePrintPos.instance;
List<BlueDevice> _blueDevices = <BlueDevice>[];
BlueDevice? _selectedDevice;
bool _isLoading = false;
int _loadingAtIndex = -1;
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Blue Print Pos'),
),
```
body: SafeArea(
child: _isLoading && _blueDevices.isEmpty
? const Center(
child: CircularProgressIndicator(
valueColor: AlwaysStoppedAnimation<Color>(Colors.blue),
),
)
: _blueDevices.isNotEmpty
? SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Column(
children: List<Widget>.generate(_blueDevices.length, (int index) {
return ListTile(
onTap:
_blueDevices[index].address == (_selectedDevice?.address ?? '')
? _onDisconnectDevice
: () => _onSelectDevice(index),
leading: Icon(Icons.print),
title: Text(
_blueDevices[index].name,
style: TextStyle(
color: _selectedDevice?.address == _blueDevices[index].address
? Colors.blue
: Colors.black,
fontSize: 20,
fontWeight: FontWeight.w500,
),
),
subtitle: Text(
_blueDevices[index].address,
style: TextStyle(
color: _selectedDevice?.address == _blueDevices[index].address
? Colors.blueGrey
: Colors.grey,
fontSize: 14,
fontWeight: FontWeight.w500,
),
),
trailing: (_loadingAtIndex == index && _isLoading)
? CircularProgressIndicator()
: (!_isLoading &&
_blueDevices[index].address ==
(_selectedDevice?.address ?? ''))
? TextButton(
onPressed: _onPrintReceipt,
child: Container(
color: _selectedDevice == null
? Colors.grey
: Colors.blue,
padding: const EdgeInsets.all(8.0),
child: const Text(
'Test Print',
style: TextStyle(color: Colors.white),
),
),
style: ButtonStyle(
backgroundColor:
MaterialStateProperty.resolveWith<Color>(
(Set<MaterialState> states) {
if (states.contains(MaterialState.pressed)) {
return Theme.of(context)
.colorScheme
.primary
.withOpacity(0.5);
}
return Theme.of(context).primaryColor;
},
),
),
)
: SizedBox(),
);
}),
),
],
),
)
```
: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: const <Widget>[
Text(
'Scan bluetooth device',
style: TextStyle(fontSize: 24, color: Colors.blue),
),
Text(
'Press button scan',
style: TextStyle(fontSize: 14, color: Colors.grey),
),
],
),
),
),
floatingActionButton: FloatingActionButton(
onPressed: _isLoading ? null : _onScanPressed,
child: _isLoading ? Icon(Icons.refresh) : Icon(Icons.search),
backgroundColor: _isLoading ? Colors.grey : Colors.blue,
),
),
);
}
Future
void _onDisconnectDevice() { _bluePrintPos.disconnect().then((ConnectionStatus status) { if (status == ConnectionStatus.disconnect) { setState(() { _selectedDevice = null; }); } }); }
void _onSelectDevice(int index) { setState(() { _isLoading = true; _loadingAtIndex = index; }); final BlueDevice blueDevice = _blueDevices[index]; _bluePrintPos.connect(blueDevice).then((ConnectionStatus status) { if (status == ConnectionStatus.connected) { setState(() => _selectedDevice = blueDevice); } else if (status == ConnectionStatus.timeout) { _onDisconnectDevice(); } else { print('$runtimeType - something wrong'); } setState(() => _isLoading = false); }); }
Future
/// Example for Print Text
ReceiptSectionText receiptText = ReceiptSectionText();
receiptText.addSpacer();
receiptText.addText(
'MY STORE',
);
receiptText.addText(
'Black White Street, Jakarta, Indonesia',
);
receiptText.addSpacer(useDashed: true);
receiptText.addLeftRightText('Time', '04/06/21, 10:00');
receiptText.addSpacer(useDashed: true);
receiptText.addLeftRightText(
'Apple 1kg',
'Rp30.000',
);
receiptText.addSpacer(useDashed: true);
receiptText.addLeftRightText(
'TOTAL',
'Rp30.000',
);
receiptText.addSpacer(useDashed: true);
receiptText.addLeftRightText(
'TOTAL',
'Rp30.000',
);
receiptText.addSpacer(useDashed: true);
receiptText.addLeftRightText(
'Payment',
'Cash',
);
//receiptText.addSpacer(count: 2);
await _bluePrintPos.printReceiptText(receiptText,paperSize: PaperSize.mm80);
await _bluePrintPos.printReceiptText(receiptText,paperSize: PaperSize.mm72);
await _bluePrintPos.printReceiptText(receiptText,paperSize: PaperSize.mm58);
await _bluePrintPos.printReceiptText(receiptText);
// /// Example for print QR
// await _bluePrintPos.printQR('www.google.com', size: 250);
// /// Text after QR
// final ReceiptSectionText receiptSecondText = ReceiptSectionText();
// receiptSecondText.addText('Powered by ayeee', size: ReceiptTextSizeType.small);
// receiptSecondText.addSpacer();
//await _bluePrintPos.printReceiptText(receiptSecondText, feedCount: 1);
}
}
`
I am facing the same issue.
Hello,
I have the same issue with Samsung Note 9. It's worked well on iPhone8.
Thanks Author, it's an amazing print library! Hope you provide a fixed bug early time.
same issue on android, with a blackview phone
hacked it by passing paperSize: PaperSize.mm80 for 50mm
How can you set the paperSize: PaperSize.mm80 @flutter-painter ?
@marcosjsfraga the method printReceiptText takes optionnal param paperSize :
if (Platform.isAndroid) {
_bluePrintPos.printReceiptText(
_receiptText,
paperSize: PaperSize.mm80,
);
}
@flutter-painter I tried something like yours but when I add PaperSize.mm80 , there is an error message , undefined name PaperSize
Sorry, i forget to add import 'package:esc_pos_utils_plus/esc_pos_utils.dart';
@Subarkah7 ill try that
@nasibudesign @marcosjsfraga @KimGiay @marcosjsfraga @Subarkah7 @nasibudesign
Please use this patch: https://github.com/andriyoganp/blue_print_pos/issues/59#issuecomment-1364622485
In file lib/blue_print_pos.dart
-
Add patch code:
paperSize = Platform.isAndroid ? PaperSize.mm72 : paperSize;
orpaperSize = Platform.isAndroid ? PaperSize.mm80 : paperSize;
-
Reference: