Closed psovit closed 1 year ago
@psovit Thank you for great work. What's your Flutter version? I think we need to keep it works both in Flutter 2 and Flutter 3.
Hi @jiusanzhou , Here's my Flutter version info:
Flutter 3.0.1 • channel stable • https://github.com/flutter/flutter.git
Framework • revision fb57da5f94 (7 months ago) • 2022-05-19 15:50:29 -0700
Engine • revision caaafc5604
Tools • Dart 2.17.1 • DevTools 2.12.2
Please feel free to modify this merge request or handle the issue on your own way 👍
If you could update the plugin with the fix, that would be really helpful as I am currently in need of this package :)
HI @jiusanzhou , I am still checking out the package and the change I submitted. I would suggest you also make sure my change is working before publishing the package as I am still seeing some related issues...
@psovit ok, thank you for PR, I will do some recheck before publishing it in few days later.
Hello @jiusanzhou, @psovit, I was checking the example app when I encountered the below error -
logs of interest
D/FloatWindow(26278): [window] start window: assitive_touch
...
D/FloatWindow(26278): [window] update window assitive_touch => {entry=main, width=154, height=154}
E/MethodChannel#im.zoe.labs/flutter_floatwing/window(26278): Failed to handle method call
E/MethodChannel#im.zoe.labs/flutter_floatwing/window(26278): java.lang.ClassCastException: java.lang.Long cannot be cast to java.lang.Integer
E/MethodChannel#im.zoe.labs/flutter_floatwing/window(26278): at im.zoe.labs.flutter_floatwing.FloatWindow$Config$Companion.from(FloatWindow.kt:502)
In short, if you run the example app (with the main
branch) and Open the assitive_touch
route, the above will be the exceptions. Visually, there's nothing noticeable but if you use VS Code to debug, it will catch the error. (It should also be noted that if you Close the route, and re-Open it, no exceptions are raised)
I looked at the #3 and found this PR. Now the error says java.lang.Long cannot be cast to java.lang.Integer so I used the old cast i.e.
cfg.callback = data["callback"] as Long?
and conveniently the exception goes away as well.
At all, I'm a bit confused. This PR should resolve the issue that was arising before, but now maybe it's raising another one or maybe not. Do let me know if I'm missing something here and excuse my insufficient knowledge on kotlin.
Hi @mulaRahul Thank you for information, I think that is I had made some mistake on this fixing. I will retest it and try to figure it out.
Fix for
java.lang.ClassCastException
in Flutter environment :sdk: ">=2.12.0 <3.0.0"
. Reference to issue: java.lang.ClassCastException in Flutter environment : sdk: ">=2.12.0 <3.0.0".Solved by first casting to
Int?
and then toLong?
.