Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Still Getting Small #46

Open
nasibudesign opened this issue Feb 23, 2022 · 10 comments
Open

Still Getting Small #46

nasibudesign opened this issue Feb 23, 2022 · 10 comments

Comments

@nasibudesign
Copy link

nasibudesign commented Feb 23, 2022

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 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);
  }
}
`
@MayurPoptaniHouzeo
Copy link

I am facing the same issue.

@KimGiay
Copy link

KimGiay commented Mar 20, 2022

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.

@flutter-painter
Copy link

same issue on android, with a blackview phone

@flutter-painter
Copy link

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

@marcosjsfraga
Copy link

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

@flutter-painter
Copy link

@marcosjsfraga the method printReceiptText takes optionnal param paperSize :

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

@Subarkah7
Copy link

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

@Subarkah7
Copy link

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

@nasibudesign
Copy link
Author

@Subarkah7 ill try that

@ankush-ppie
Copy link

@nasibudesign @marcosjsfraga @KimGiay @marcosjsfraga @Subarkah7 @nasibudesign

Please use this patch:
#59 (comment)

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants