Skip to content

Conversation

@rishad13
Copy link

This pull request updates the ExternalDisplayPlugin in ExternalDisplayPlugin.kt to improve robustness and debugging, especially around context handling and argument parsing. The changes ensure safer use of the context property, improve logging for easier debugging, and make argument extraction from Flutter method calls more reliable.

Context handling and safety:

  • Changed context from a non-nullable to a nullable property and added null checks before usage to prevent crashes. Used context!! only after confirming non-null. [1] [2]
  • Ensured context is only set in onAttachedToEngine if it hasn't already been set, avoiding unnecessary overwrites.

Argument parsing improvements:

  • Switched from parsing method call arguments as a JSON string to extracting them directly as a Map<String, Any>, reducing parsing errors and improving type safety.

Debugging and logging:

  • Added debug log statements in onMethodCall and specifically in the "connect" method to help trace incoming method calls and argument states. [1] [2]

Error handling:

  • Improved error handling in the "connect" method by returning false when preconditions (such as available displays or valid context) are not met, ensuring clearer feedback to the Flutter side.

Closes #7

@rishad13
Copy link
Author

@GavinFu7 @ritick-plateron

@rishad13
Copy link
Author

i need this to use this plugin on my project

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.

MissingPluginException(No implementation found for method connect on channel displayController)

2 participants