blue_print_pos icon indicating copy to clipboard operation
blue_print_pos copied to clipboard

Still Getting Small

Open nasibudesign opened this issue 3 years ago • 10 comments

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,

IMG_3406

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 _onScanPressed() async { setState(() => _isLoading = true); _bluePrintPos.scan().then((List<BlueDevice> devices) { if (devices.isNotEmpty) { setState(() { _blueDevices = devices; _isLoading = false; }); } else { setState(() => _isLoading = false); } }); }





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 _onPrintReceipt() async { /// Example for Print Image final ByteData logoBytes = await rootBundle.load( 'assets/logo.jpg', ); await _bluePrintPos.printReceiptImage(logoBytes.buffer.asUint8List());


    /// 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);
  }
}
`

nasibudesign avatar Feb 23 '22 17:02 nasibudesign

I am facing the same issue.

MayurPoptaniHouzeo avatar Mar 10 '22 19:03 MayurPoptaniHouzeo

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.

KimGiay avatar Mar 20 '22 17:03 KimGiay

same issue on android, with a blackview phone

flutter-painter avatar Apr 09 '22 15:04 flutter-painter

hacked it by passing paperSize: PaperSize.mm80 for 50mm

flutter-painter avatar Apr 10 '22 08:04 flutter-painter

How can you set the paperSize: PaperSize.mm80 @flutter-painter ?

marcosjsfraga avatar Apr 21 '22 15:04 marcosjsfraga

@marcosjsfraga the method printReceiptText takes optionnal param paperSize :

if (Platform.isAndroid) {
    _bluePrintPos.printReceiptText(
      _receiptText,
      paperSize: PaperSize.mm80,
    );
  }

flutter-painter avatar Apr 23 '22 09:04 flutter-painter

@flutter-painter I tried something like yours but when I add PaperSize.mm80 , there is an error message , undefined name PaperSize

Subarkah7 avatar Aug 10 '22 07:08 Subarkah7

Sorry, i forget to add import 'package:esc_pos_utils_plus/esc_pos_utils.dart';

Subarkah7 avatar Aug 10 '22 08:08 Subarkah7

@Subarkah7 ill try that

nasibudesign avatar Aug 30 '22 17:08 nasibudesign

@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; or paperSize = Platform.isAndroid ? PaperSize.mm80 : paperSize;

  • Reference: Screenshot 2022-12-25 at 9 20 38 AM

ankush-ppie avatar Dec 25 '22 04:12 ankush-ppie