andrey-ushakov / esc_pos_utils

Basic Flutter/Dart classes for ESC/POS printing
BSD 3-Clause "New" or "Revised" License
140 stars 304 forks source link

Request upgrade image version #114

Open in-ealcocer opened 1 year ago

in-ealcocer commented 1 year ago

I can't add this dependency because it depends on a lower version of the image package. It also isn't compatible with the newest version of flutter. My question is if are you planning on upgrading the dependency? Here is the error log: `The current Dart SDK version is 3.0.3.

Because esc_pos_printer >=4.1.0 depends on image ^3.0.2 and esc_pos_printer <4.1.0 doesn't support null safety, every version of esc_pos_printer requires image ^3.0.2. So, because thor depends on both image ^4.0.17 and esc_pos_printer
any, version solving failed.

The lower bound of "sdk: '>=2.1.0 <3.0.0'" must be 2.12.0 or higher to enable null safety. For details, see https://dart.dev/null-safety`

huakaihualuo01 commented 1 year ago

I had the same problem

Resolving dependencies... The lower bound of "sdk: '>=2.1.0 <3.0.0'" must be 2.12.0' or higher to enable null safety.

The current Dart SDK (3.0.5) only supports null safety.

For details, see https://dart.dev/null-safety

wrjcs commented 11 months ago

@waqadArshad does it work?

wrjcs commented 11 months ago

I have this result fcbb1aff8f958ea2f892ff4929f4bca

waqadArshad commented 11 months ago

@wrjcs for an image, or for normal print? coz I just updated the image version and implemented the required updates in the code based on the changed functions in the image package and I tried to be very careful in that. Please let me know what you are having issues with and I'll update you after checking it again.

wrjcs commented 11 months ago

For image It got your code, I print it as the image above Did you teste your code, does it work correctly?

waqadArshad commented 11 months ago

@wrjcs as far as text based print is concerned, yes, I did test it and it was working properly. But I did not test it with an image so can't surely say anything about that. and for your print, I cannot make out if it was a text based print or an image based one. so let me know which one is that and I'll check it.

waqadArshad commented 11 months ago

@wrjcs ok. sorry, I misread your message. So it was an image. As I mentioned, I did not test it with an image. And if you can wait, I'm kinda busy tomorrow, so I'll probably check this on Monday. Please make sure to remind me about that. Thanks

wrjcs commented 11 months ago

@waqadArshad Thank you for your réponse. Sure, I can wait I’m waiting for you

waqadArshad commented 11 months ago

@wrjcs can you please share this image here? I mean the image that you are trying to print. Thanks

waqadArshad commented 11 months ago

@wrjcs I checked and it prints alright. I don't think the problem is with this package. You should check your implementation or your printer settings.

I just printed this image: 5665450

and this is the result: printed image

I printed more images than just this one but I'm adding this one for your reference.

Please let me know if you need any more help.

wrjcs commented 11 months ago

hello, this is my image original 20230724105444 could you give the the code that you load image and print Thanks.

waqadArshad commented 11 months ago

@wrjcs Sure, here it is:

Use the following import:

import 'package:image/image.dart' as img;

And then use this in your print method.


 List<int> bytes = [];
    // Xprinter XP-N160I
    final profile = await CapabilityProfile.load(name: 'XP-N160I');
    final generator = Generator(PaperSize.mm80, profile);
    bytes += generator.setGlobalCodeTable('CP1252');
    bytes += generator.text('Test Print', styles: const PosStyles(align: PosAlign.center));
    bytes += generator.hr();

    //+ ~~~~~~~~~~~~~~~~~~~~~~~~ Image Section ~~~~~~~~~~~~~~~~~~~~~~~~~~~

    final ByteData data = await rootBundle.load(Assets.checkImages5665450);
    final Uint8List imageBytes = data.buffer.asUint8List();
    final img.Image image = img.decodeImage(imageBytes)!;

    final img.Image resized = img.copyResize(image, width: 558);
    bytes += generator.image(resized);

    //! ~~~~~~~~~~~~~~~~~~~~~~~~ Image Section End ~~~~~~~~~~~~~~~~~~~~~~~~~

    // printEscPos is the default method from another package (link provided below):    
    printEscPos(bytes, generator, context);
  }

printEscPos is the default method from the example of: flutter_pos_printer_platform

waqadArshad commented 11 months ago

@andrey-ushakov if you can delete my comments, telling people to use my fork in which I was also going to add all (or most of) the code from the Pull Requests and definitely do extensive testing for each, then I believe you can also maintain the repo. I was not trying to take over your package or something. It was always going to be your fork, I just wanted to get the users an updated version of it. But it's alright. I just wanted to say this because I and all other users need you to either maintain it or assign someone else to maintain this package. Many developers depend on it, so please consider this a humble request and update and maintain the package.

And Thanks a lot for this amazing package. I appreciate the efforts and time you put into it. And I am extremely sorry for any misunderstanding.

TamirlanBir commented 5 months ago

@waqadArshad Hello ! can u help me with this error RangeError (index): Invalid value: Not in inclusive range 0..9638: 9639

waqadArshad commented 5 months ago

what is causing this @TamirlanBir?