Conversation
Android에서 Flutter HapticFeedback API의 light/medium/heavy가 실제 체감 강도와 불일치하는 문제를 vibration 패키지의 amplitude 직접 제어로 해결. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Android에서 HapticFeedback의 light/medium/heavy 체감 강도가 뒤섞이는 문제를 해결하기 위해, Android(Amplitude 지원)에서는 vibration 패키지로 amplitude를 직접 제어하고 그 외(iOS/미지원 Android)는 기존 HapticFeedback로 fallback 하도록 변경한 PR입니다.
Changes:
vibration패키지 의존성 추가DeviceBridgeHandler.triggerHaptic()에서 Android amplitude 지원 시 타입별 duration/amplitude로 진동 호출pubspec.lock에 신규/전이 의존성 반영
Reviewed changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| pubspec.yaml | vibration 패키지 추가로 Android 진동 amplitude 제어 기반 마련 |
| pubspec.lock | vibration 및 관련 전이 의존성 잠금 반영 |
| lib/bridge/handlers/device_bridge_handler.dart | Android는 amplitude 기반 진동으로 보정, iOS/미지원 Android는 기존 API 유지 |
| Vibration.vibrate(duration: 50, amplitude: 30); | ||
| break; | ||
| case 'medium': | ||
| Vibration.vibrate(duration: 43, amplitude: 50); | ||
| break; | ||
| case 'heavy': | ||
| Vibration.vibrate(duration: 60, amplitude: 70); | ||
| break; | ||
| case 'selection': | ||
| Vibration.vibrate(duration: 20, amplitude: 20); | ||
| break; | ||
| case 'vibrate': | ||
| Vibration.vibrate(duration: 500, amplitude: 128); |
There was a problem hiding this comment.
Vibration.vibrate(...)를 await하지 않아, 플러그인 채널 에러/예외가 발생해도 현재 try/catch에서 잡히지 않고 unhandled Future error로 남을 수 있습니다. 동일한 메서드 내에서 iOS 경로는 await HapticFeedback...로 처리하고 있으니, Android amplitude 경로도 await로 통일하거나(권장) 의도적으로 fire-and-forget이면 unawaited(...) + 에러 처리로 명시해 주세요.
| Vibration.vibrate(duration: 50, amplitude: 30); | |
| break; | |
| case 'medium': | |
| Vibration.vibrate(duration: 43, amplitude: 50); | |
| break; | |
| case 'heavy': | |
| Vibration.vibrate(duration: 60, amplitude: 70); | |
| break; | |
| case 'selection': | |
| Vibration.vibrate(duration: 20, amplitude: 20); | |
| break; | |
| case 'vibrate': | |
| Vibration.vibrate(duration: 500, amplitude: 128); | |
| await Vibration.vibrate(duration: 50, amplitude: 30); | |
| break; | |
| case 'medium': | |
| await Vibration.vibrate(duration: 43, amplitude: 50); | |
| break; | |
| case 'heavy': | |
| await Vibration.vibrate(duration: 60, amplitude: 70); | |
| break; | |
| case 'selection': | |
| await Vibration.vibrate(duration: 20, amplitude: 20); | |
| break; | |
| case 'vibrate': | |
| await Vibration.vibrate(duration: 500, amplitude: 128); |
There was a problem hiding this comment.
Fixed in 2daa22d.
변경 내용: 모든 Vibration.vibrate() 호출에 await 추가
이유: iOS 경로와 동일하게 await로 통일하여 try/catch에서 에러를 정상적으로 캐치할 수 있도록 수정
Addresses review comment by @copilot-pull-request-reviewer on device_bridge_handler.dart:66. PR: #10
변경 사항
HapticFeedbackAPI의light/medium/heavy강도가 실제 체감과 불일치하는 문제 수정vibration패키지를 도입하여 Android에서 amplitude(0~255)를 직접 제어HapticFeedbackAPI 유지 (Apple이 강도 순서를 보장하므로 문제 없음)원인
Flutter의
heavyImpact()→ AndroidCONTEXT_CLICK(마우스 우클릭용, OEM이 약하게 튜닝)Flutter의
lightImpact()→ AndroidVIRTUAL_KEY(키보드 탭용, OEM이 강하게 튜닝)Android의
HapticFeedbackConstants는 강도 스케일이 아닌 UI 맥락 레이블이며, 실제 강도는 OEM별로 상이함적용 amplitude 값
lightmediumheavyselectionvibrate레벨 간 최소 1.4배 차이 유지 (Android Haptics Design Principles)
테스트
관련 이슈
🤖 Generated with Claude Code
Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com