-
-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Support for Web #48
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution! I will be super cool to have support on web too, I have left some comments, let me know of anything
packages/gamepads_web/pubspec.yaml
Outdated
flutter_web_plugins: | ||
sdk: flutter | ||
gamepads_platform_interface: ^0.1.2+1 | ||
js: ^0.6.3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe that the dart:js
package is deprecated: https://dart.dev/interop/js-interop
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for reminding! I have updated to use js_interop and package:web instead of package:js and dart:html.
final gamepads = navigator.getGamepads(); | ||
return List.generate(gamepads.length, (i) { | ||
final gamepad = gamepads[i]; | ||
if (gamepad != null) { | ||
return gamepad; | ||
} | ||
return null; | ||
}).where((gamepad) => gamepad != null).toList(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
final gamepads = navigator.getGamepads(); | |
return List.generate(gamepads.length, (i) { | |
final gamepad = gamepads[i]; | |
if (gamepad != null) { | |
return gamepad; | |
} | |
return null; | |
}).where((gamepad) => gamepad != null).toList(); | |
return navigator.getGamepads().toDart.whereNotNull(); |
Shouldn't this be enough?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did't notice that I can use gamepad in package:web. Updated the implementation.
return controllers; | ||
} | ||
|
||
List<dynamic> getGamepadList() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't the list be typed here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did't get it well. Does the latest implementation look fine?
I am developing an app requiring web support for gamepads. I would like to contribute to this project. Please help review this pull request. Thanks!