[Feature] Add multi-platform safety#20
Open
austinn wants to merge 1 commit into
Open
Conversation
…b, macOS, Windows, Linux, and other desktop/mobile targets)
istornz
requested changes
Jun 7, 2026
istornz
left a comment
Owner
There was a problem hiding this comment.
Thanks for you PR, I let some little comments 👍
| class Gaimon { | ||
| static const MethodChannel _channel = MethodChannel('gaimon'); | ||
|
|
||
| static bool get _isAndroid => !kIsWeb && Platform.isAndroid; |
Owner
There was a problem hiding this comment.
I think this is enough, same for iOS
Suggested change
| static bool get _isAndroid => !kIsWeb && Platform.isAndroid; | |
| static bool get _isAndroid => Platform.isAndroid; |
Author
There was a problem hiding this comment.
Sorry @istornz I'm not sure I'm following - web doesn't support the Platform API - so why wouldn't we add this before a native platform check?
|
|
||
| static bool get _isAndroid => !kIsWeb && Platform.isAndroid; | ||
| static bool get _isIOS => !kIsWeb && Platform.isIOS; | ||
| static bool get _supportsMethodChannel => _isAndroid || _isIOS; |
Owner
There was a problem hiding this comment.
Maybe adding the kIsWeb in this condition is better?
Author
There was a problem hiding this comment.
@istornz This package only supports Android and iOS, so I'm not sure why adding a kIsWeb would be useful here.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Addresses: #19
This PR resolves issues when using the
gaimonpackage in multi-platform Flutter applications (e.g. Web, macOS, Windows, Linux).Previously, the package would:
Solution
kIsWebguards to safely short-circuitPlatformchecks on the Web.MethodChannelinvocations (_channel.invokeMethod) to ensure they are only triggered on supported mobile platforms (Android and iOS).try-catchsafety tocanSupportsHapticto fallback tofalsein case of unexpected platform errors.HapticFeedback.selectionClick(),HapticFeedback.heavyImpact()) to run untouched as they are natively stubbed/handled safely on all platforms by Flutter.Documentation
Documented platform compatibility and fallback behavior in
README.md