kipluo
Flutter7 min read4 steps

How to Add Haptics and Sound to Flutter Buttons

Haptics and sound make a tap feel received, but the Flutter APIs behave differently per platform. This guide explains HapticFeedback's methods, why Feedback.forTap does nothing on iOS, how to keep feedback subtle, and how to add short synthesized sounds with Kipluo.

You needFlutter 3.xpackage:flutter/services.dartA real device (simulators don't vibrate)
Loading demo
The web version of Favorite Toggle, with its pop and sparkle sounds. On a phone, pair it with a light haptic.Component page

1. The HapticFeedback methods

HapticFeedback in package:flutter/services.dart triggers the platform's built-in haptic patterns. On iOS they map to the system impact and selection generators; on Android they use the view's haptic feedback constants, so the feel depends on the device's motor and the user's touch-feedback setting.

  • selectionClick(): a very light tick for changing a selection, such as a picker, segmented control or toggle.
  • lightImpact(): a light tap for ordinary button presses and small confirmations.
  • mediumImpact(): something snapping into place, like a drag reaching a detent.
  • heavyImpact(): rare, for significant moments. Overuse makes the app feel noisy.
  • vibrate(): a plain vibration. Avoid it for UI taps; it is long and coarse.

2. Add a haptic to a button

Call the haptic in the same callback that performs the action, so it happens exactly when the press is accepted. Haptics are fire-and-forget; you don't need to await them.

feedback_button.dart
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

class FeedbackButton extends StatelessWidget {
  const FeedbackButton({super.key, required this.label, required this.onPressed});

  final String label;
  final VoidCallback onPressed;

  @override
  Widget build(BuildContext context) {
    return FilledButton(
      onPressed: () {
        HapticFeedback.lightImpact();
        onPressed();
      },
      child: Text(label),
    );
  }
}

3. System click sounds and Feedback.forTap

Material buttons, InkWell and ListTile already call Feedback.forTap when enableFeedback is true (the default). On Android that plays the system click sound, which respects the user's touch-sound setting. On iOS it does nothing, because iOS has no system tap sound for apps.

SystemSound.play(SystemSoundType.click) is the lower-level call behind it and has the same platform limits. If you need a tap sound on iOS, or a sound that means something specific (sent, saved, error), you have to play your own audio.

4. Synthesized sounds with Kipluo, plus your haptic

Kipluo widgets play short synthesized sounds (pops, ticks, chimes) through flutter_soloud on every platform, panned toward where the widget is on screen. They don't trigger haptics themselves, so add a HapticFeedback call in the widget's callback.

The free Favorite Toggle below plays its pop and sparkle on its own; the haptic is the one line you add. KipluoSound.play lets your own widgets use the same sounds, and KipluoSound.enabled is the global mute.

like_button.dart
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:kipluo/kipluo.dart';

class LikeButton extends StatefulWidget {
  const LikeButton({super.key});

  @override
  State<LikeButton> createState() => _LikeButtonState();
}

class _LikeButtonState extends State<LikeButton> {
  bool _liked = false;

  @override
  Widget build(BuildContext context) {
    return FavoriteToggle(
      pressed: _liked,
      label: 'Like',
      onChanged: (v) {
        HapticFeedback.lightImpact();
        setState(() => _liked = v);
      },
    );
  }
}

// Your own widget, same sound set:
Builder(
  builder: (context) => TextButton(
    onPressed: () {
      HapticFeedback.selectionClick();
      KipluoSound.play(KSound.pop, at: context); // panned to this button
      send();
    },
    child: const Text('Send'),
  ),
);

Accessibility checklist

Tick each one off as you check your build. Your ticks stay in this browser.

0 of 4 checked

Build it yourself or install it

Build it yourself when

Haptics only. HapticFeedback calls in your callbacks need no package.

Install Kipluo when

You want tap sounds on iOS and Android, matched to each widget's motion, with stereo placement and a global mute.

Keep building