syncfusion / flutter-widgets

Syncfusion Flutter widgets libraries include high quality UI widgets and file-format packages to help you create rich, high-quality applications for iOS, Android, and web from a single code base.
1.55k stars 756 forks source link

Sticky note insert problem (RangeError (length): Invalid value: Only valid value is 0: 1) #2026

Open wildsurfer opened 4 weeks ago

wildsurfer commented 4 weeks ago

Bug description

I'm trying to enable the stickyNote annotation mode. A popup opens fine but when I press the INSERT button I'm facing the RangeError (length): Invalid value: Only valid value is 0: 1 exception.

Steps to reproduce

  1. Run the example code.
  2. Press anywhere in the document.
  3. Type any text and press INSERT.
  4. Check the application log.

Code sample

Code sample ```dart import 'package:flutter/material.dart'; import 'package:syncfusion_flutter_pdfviewer/pdfviewer.dart'; final pdfViewerController = PdfViewerController(); void main() { runApp(const MyApp()); } class MyApp extends StatelessWidget { const MyApp({super.key}); @override Widget build(BuildContext context) { return const MaterialApp( title: 'PDF Viewer with Annotation', home: PdfViewerScreen(), ); } } class PdfViewerScreen extends StatelessWidget { const PdfViewerScreen({super.key}); @override Widget build(BuildContext context) { pdfViewerController.annotationMode = PdfAnnotationMode.stickyNote; return Scaffold( appBar: AppBar( title: const Text('PDF Viewer with Annotation'), ), body: SfPdfViewer.network( 'https://www.buds.com.ua/images/Lorem_ipsum.pdf', controller: pdfViewerController, // enableTextSelection: true, ), ); } } ```

Screenshots or Video

Screenshots / Video demonstration ![image](https://github.com/user-attachments/assets/2275ab25-8a50-4c8d-a19e-febe5bc67f8b)

Stack Traces

Stack Traces ```dart Launching lib/main.dart on iPad (10th generation) in debug mode... Running pod install... Running Xcode build... Xcode build done. 37.9s Debug service listening on ws://127.0.0.1:52337/bx-Zz_3a2iU=/ws Syncing files to device iPad (10th generation)... ======== Exception caught by gesture =============================================================== The following RangeError was thrown while handling a gesture: RangeError (length): Invalid value: Only valid value is 0: 1 When the exception was thrown, this was the stack: #0 List.[] (dart:core-patch/growable_array.dart) #1 PdfArray._getElement (package:syncfusion_flutter_pdf/src/pdf/implementation/primitives/pdf_array.dart:53:20) #2 PdfArray.[] (package:syncfusion_flutter_pdf/src/pdf/implementation/primitives/pdf_array.dart:51:44) #3 PdfPageCollection._returnValue (package:syncfusion_flutter_pdf/src/pdf/implementation/pages/pdf_page_collection.dart:246:49) #4 PdfPageCollection.[] (package:syncfusion_flutter_pdf/src/pdf/implementation/pages/pdf_page_collection.dart:62:37) #5 SfPdfViewerState._addSticyNoteAnnotation (package:syncfusion_flutter_pdfviewer/src/pdfviewer.dart:4555:25) #6 SfPdfViewerState._showStickyNoteDialogMobile... (package:syncfusion_flutter_pdfviewer/src/pdfviewer.dart:4647:37) #7 _InkResponseState.handleTap (package:flutter/src/material/ink_well.dart:1170:21) #8 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:351:24) #9 TapGestureRecognizer.handleTapUp (package:flutter/src/gestures/tap.dart:656:11) #10 BaseTapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:313:5) #11 BaseTapGestureRecognizer.handlePrimaryPointer (package:flutter/src/gestures/tap.dart:246:7) #12 PrimaryPointerGestureRecognizer.handleEvent (package:flutter/src/gestures/recognizer.dart:703:9) #13 PointerRouter._dispatch (package:flutter/src/gestures/pointer_router.dart:98:12) #14 PointerRouter._dispatchEventToRoutes. (package:flutter/src/gestures/pointer_router.dart:143:9) #15 _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:633:13) #16 PointerRouter._dispatchEventToRoutes (package:flutter/src/gestures/pointer_router.dart:141:18) #17 PointerRouter.route (package:flutter/src/gestures/pointer_router.dart:127:7) #18 GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:501:19) #19 GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:481:22) #20 RendererBinding.dispatchEvent (package:flutter/src/rendering/binding.dart:450:11) #21 GestureBinding._handlePointerEventImmediately (package:flutter/src/gestures/binding.dart:426:7) #22 GestureBinding.handlePointerEvent (package:flutter/src/gestures/binding.dart:389:5) #23 GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:336:7) #24 GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:305:9) #25 _invoke1 (dart:ui/hooks.dart:328:13) #26 PlatformDispatcher._dispatchPointerDataPacket (dart:ui/platform_dispatcher.dart:442:7) #27 _dispatchPointerDataPacket (dart:ui/hooks.dart:262:31) Handler: "onTap" Recognizer: TapGestureRecognizer#2b985 debugOwner: GestureDetector state: possible won arena finalPosition: Offset(665.0, 180.0) finalLocalPosition: Offset(43.1, 21.5) button: 1 sent tap down ==================================================================================================== ```

On which target platforms have you observed this bug?

iOS

Flutter Doctor output

Doctor output ```console [✓] Flutter (Channel stable, 3.24.0, on macOS 14.5 23F79 darwin-arm64, locale en-UA) • Flutter version 3.24.0 on channel stable at /Users/kuzma/Flutter/flutter • Upstream repository git@github.com:flutter/flutter.git • Framework revision 80c2e84975 (2 weeks ago), 2024-07-30 23:06:49 +0700 • Engine revision b8800d88be • Dart version 3.5.0 • DevTools version 2.37.2 [✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0-rc3) • Android SDK at /Users/kuzma/Library/Android/sdk • Platform android-34, build-tools 34.0.0-rc3 • Java binary at: /opt/homebrew/opt/openjdk@17/bin/java • Java version OpenJDK Runtime Environment Homebrew (build 17.0.11+0) • All Android licenses accepted. [✓] Xcode - develop for iOS and macOS (Xcode 15.3) • Xcode at /Applications/Xcode.app/Contents/Developer • Build 15E204a • CocoaPods version 1.15.2 [✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome [!] Android Studio (not installed) • Android Studio not found; download from https://developer.android.com/studio/index.html (or visit https://flutter.dev/to/macos-android-setup for detailed instructions). [✓] IntelliJ IDEA Ultimate Edition (version 2024.1.4) • IntelliJ at /Applications/IntelliJ IDEA.app • Flutter plugin version 80.0.2 • Dart plugin version 241.18808 [✓] Connected device (5 available) • Ivan’s iPhone (mobile) • 00008101-000858AC1189003A • ios • iOS 17.5.1 21F90 • iPad (10th generation) (mobile) • 80D1A072-0384-4BFA-BE86-C2C8A73E02F4 • ios • com.apple.CoreSimulator.SimRuntime.iOS-17-4 (simulator) • macOS (desktop) • macos • darwin-arm64 • macOS 14.5 23F79 darwin-arm64 • Mac Designed for iPad (desktop) • mac-designed-for-ipad • darwin • macOS 14.5 23F79 darwin-arm64 • Chrome (web) • chrome • web-javascript • Google Chrome 127.0.6533.101 ! Error: Browsing on the local area network for Ivan’s Apple Watch. Ensure the device is unlocked and discoverable via Bluetooth. (code -27) [✓] Network resources • All expected network resources are available. ```
wildsurfer commented 4 weeks ago

After some additional debugging, I realized that the issue was related to the PDF file. If I use another PDF file it works fine.

immankumarsync commented 4 weeks ago

@wildsurfer, this is a known issue, and we have resolved it. The fix will be included in the upcoming weekly release, expected on August 20, 2024.

immankumarsync commented 3 weeks ago

@wildsurfer, we have resolved the reported issue and fix is available in our latest weekly release. Package link: syncfusion_flutter_pdfviewer v26.2.10

Kindly let us know whether the issue is resolved on your end.