Closed UnluckyY1 closed 1 week ago
Hi,
Thank you for your feedback on using dynamic as a return type. While I understand the benefits of specifying explicit return types, in this case, dynamic was used to maintain flexibility across different platform implementations and handle various data structures.
The current implementation allows for easier integration with the platform channels without tightly coupling to a specific data model. This approach is intended to accommodate potential variations in the data format returned by the native code.
If you have suggestions on how to better balance flexibility and type safety while using dynamic, I'd be happy to consider them. Your input is valuable for improving the library.
Thanks for your understanding!
I will try to create a PR soon with my suggestions. :)
In Dart, using dynamic as a return type is generally considered poor practice. It undermines the type safety provided by the language and can lead to runtime errors that could have been caught at compile time. It's recommended to specify the return type explicitly to make your code easier to understand, maintain, and debug...
I've reviewed the Android portion of the code and noticed that it returns a map containing a Uri for the file and a page count. While I'm uncertain about the return type used in the iOS section, it should be relatively straightforward to establish a universal return type within the Dart codebase
This can be done simply by creating a simple data class that can deserialize JSON objects:
and then inside : flutter_doc_scanner_method_channel.dart: