Skip to content

Conversation

anggaprytn
Copy link

Fix: Handle Nullable Map and Enum Mismatch in MarkTextOptions.kt

Description

This PR addresses two issues in MarkTextOptions.kt:

  1. Nullable ReadableMap handling
    ReadableArray.getMap(index) returns a nullable ReadableMap?, but was passed directly into the TextOptions constructor, which expects a non-null ReadableMap.
    ✅ Fixed using Kotlin's safe call with let { ... }, and explicitly throwing MarkerError if null.

  2. Incorrect enum usage
    MarkerError expects the first argument to be of type ErrorCode, but a String literal "NULL_MAP" was passed instead.
    ✅ Fixed by adding a new ErrorCode.NULL_MAP enum value and using it explicitly in the constructor.

Changes

  • Added ErrorCode.NULL_MAP to the ErrorCode enum.
  • Updated MarkTextOptions.kt to:
    • Safely handle nullable maps from ReadableArray.
    • Throw MarkerError(ErrorCode.NULL_MAP, ...) instead of passing a raw string.

Impact

  • Prevents potential NullPointerException during runtime.
  • Aligns with Kotlin’s null-safety expectations and improves type correctness.
  • No changes in public API or functionality, purely an internal safety fix.

Test

  • Build successful
  • Tested on Android emulator
  • Verified behavior with missing/null watermarkTexts input

@anggaprytn anggaprytn changed the title Handle Nullable Map and Enum Mismatch in MarkTextOptions.kt fix: Handle Nullable Map and Enum Mismatch in MarkTextOptions.kt Jul 31, 2025
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

Successfully merging this pull request may close these issues.

1 participant