【问题标题】:Vibration.vibrate works on android but the same code does not work on IOSVibration.vibrate 适用于 android,但相同的代码不适用于 IOS
【发布时间】:2021-01-30 03:50:15
【问题描述】:

试图实现一个填充词检测器,任何“喜欢”的例子都会让手机振动。我使用语音到文本 API 并在检测到“喜欢”时获取文本并振动,它适用于 Android。

class _RecognizeContent extends StatelessWidget {
    RichText processText() {
    //loops through the text string given by API
    if (filler_word_instances.containsKey(curr_word)) {
        if (!filler_word_instances[curr_word].contains(i) && recognizing && !recognizeStart) {
            Vibration.vibrate(); //---> This doesnt work
            filler_word_instances[curr_word].add(i);
        }
    }

【问题讨论】:

    标签: android ios flutter vibration


    【解决方案1】:

    您是否尝试过使用HapticFeedback?它不需要插件,适用于android和ios

    这是how to video

    【讨论】:

    • 是的,我有!不幸的是,HapticFeedback 和 Vibration 都只适用于 onPressed,但我想在 onPressed 之外使用它。例如,当 x = 'hi' 然后振动
    • 我让它在 onPressed 语句之外工作。有没有说只能作为onPressed使用?
    猜你喜欢
    • 2022-10-01
    • 2022-11-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-11-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多