andriyoganp / blue_print_pos

Helper to use bluetooth print in Android and iOS
Apache License 2.0
34 stars 77 forks source link

Unhandled Exception: RangeError (index): Index out of range: no indices are valid: 0 #28

Closed thearise closed 2 years ago

thearise commented 2 years ago

Error logs (Tested on iOS, blue_print_pos: 0.0.9)

[VERBOSE-2:ui_dart_state.cc(209)] Unhandled Exception: RangeError (index): Index out of range: no indices are valid: 0

0 _Uint8ArrayView.[] (dart:typed_data-patch/typed_data_patch.dart:4181:7)

1 InputBuffer.[] (package:image/src/util/input_buffer.dart:44:39)

2 PngDecoder.isValidFile (package:image/src/formats/png_decoder.dart:26:20)

3 findDecoderForData (package:image/src/formats/formats.dart:38:11)

4 decodeImage (package:image/src/formats/formats.dart:88:19)

5 BluePrintPos._getBytes (package:blue_print_pos/blue_print_pos.dart:233:11)

#6 BluePrintPos.printReceiptText (package:blue_print_pos/blue_print_pos.dart:130:34) ### Flutter version Flutter 2.9.0-1.0.pre.73 • channel master
thearise commented 2 years ago

I also tried with blue_print_pos: 0.0.8 and get this error

[VERBOSE-2:ui_dart_state.cc(209)] Unhandled Exception: Bad state: No element

0 ListMixin.firstWhere (dart:collection/list.dart:167:5)

1 BluePrintPos._printProcess (package:blue_print_pos/blue_print_pos.dart:199:46)

[VERBOSE-2:ui_dart_state.cc(209)] Unhandled Exception: Bad state: No element #0 ListMixin.firstWhere (dart:collection/list.dart:167:5) #1 BluePrintPos._printProcess (package:blue_print_pos/blue_print_pos.dart:199:46) [VERBOSE-2:ui_dart_state.cc(209)] Unhandled Exception: Bad state: No element #0 ListMixin.firstWhere (dart:collection/list.dart:167:5) #1 BluePrintPos._printProcess (package:blue_print_pos/blue_print_pos.dart:199:46)
iandis commented 2 years ago

Could you please provide flutter doctor -v ? We need to know what iOS version you're using

Edit: I found out that apparently the WKWebView execution block in the DispatchQueue.main.asyncAfter seems to not be able to complete when duration is below 200 (a.k.a delayed < 20 ms).

andriyoganp commented 2 years ago

It is solved in this #32. So use 0.0.10.

thearise commented 2 years ago

Although I updated to 0.0.10 and reinstalled pod file, I'm still facing the same

[VERBOSE-2:ui_dart_state.cc(209)] Unhandled Exception: Bad state: No element

0 ListMixin.firstWhere (dart:collection/list.dart:167:5)

1 BluePrintPos._printProcess (package:blue_print_pos/blue_print_pos.dart:205:46)

flutter doctor -v [✓] Flutter (Channel master, 2.9.0-1.0.pre.110, on macOS 11.6 20G165 darwin-x64, locale en-MM) • Flutter version 2.9.0-1.0.pre.110 at /Users/***/Downloads/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision 31eb8fcd98 (5 days ago), 2021-12-16 09:29:06 -0500 • Engine revision 6a62d8e12d • Dart version 2.16.0 (build 2.16.0-116.0.dev) • DevTools version 2.9.1

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2) • Android SDK at /Users/***/Library/Android/sdk • Platform android-31, build-tools 30.0.2 • Java binary at: /Applications/Android Studio 2.app/Contents/jre/jdk/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495) • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 13.0) • Xcode at /Applications/Xcode.app/Contents/Developer • CocoaPods version 1.11.2

[✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 3.4) • Android Studio at /Applications/Android Studio.app/Contents • Flutter plugin version 39.0.1 • Dart plugin version 183.6270 • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b01)

[✓] Android Studio (version 4.1) • Android Studio at /Applications/Android Studio 2.app/Contents • Flutter plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)

[✓] Connected device (2 available)

iandis commented 2 years ago

@thearise Have you paired your bluetooth printer with your device?

thearise commented 2 years ago

@iandis Sorry for the late reply.

The problem is my printer can't be scanned in the iOS default Bluetooth setting but works with esc_pos_bluetooth plugin using in-app Bluetooth scanning in iOS. Only with your wonderful plugin, printing receipt images works smoothly and faster than esc_pos_bluetooth plugin. That's why I rather use your plugin but also I don't know why your plugin can't be used to print with my printer in iOS.