如何在Flutter上为Android和iOS实施振动? [英] How to implement vibration with Flutter for both Android and iOS?
问题描述
使用Flutter,我试图在按钮单击时实现振动.
Using Flutter I am trying to implement vibration on a button click.
说实话,我发现很难做到.我尝试使用以下软件包失败: ' https://pub.dev/packages/vibration '和'
I find it surprisingly difficult to be honest. I've tried using the following packages unsuccessfully: 'https://pub.dev/packages/vibration' and 'https://pub.dev/packages/vibrate' but they just do not vibrate (talking here about the real devices not emulators/simulators).
是否有关于如何使用Flutter在iOS和Android设备上实现振动的明确示例指南?
Is there a guidance with clear examples on how to implement vibration on iOS and Android devices with Flutter?
谢谢, 密海
推荐答案
找到了使用HapticFeedback.vibrate()
的方法.它适用于iOS和Android.在此[post] [1]上查看具有代码示例和其他设置的更多详细信息: Flutter:如何使用HapticFeedback
Found a way using HapticFeedback.vibrate()
. It works for both iOS and Android. See more details with code example and other settings on this [post][1]: Flutter: How to use HapticFeedback
这篇关于如何在Flutter上为Android和iOS实施振动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!