Search packages, repositories and app categories

touchable_opacity cover
Package detailsv1.2.0

touchable_opacity

This widget lets you provide a more visual feedback to users when they interact with your app, similar to TouchableOpacity in React Native.

AndroidiOSWebmacOSWindowsLinux
30-day downloads
7K
Likes
17
Pub points
140

Install package

flutter pub add touchable_opacity

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

The touchable_opacity package provides a Flutter widget that delivers visual feedback when users interact with UI elements, mimicking the behavior of TouchableOpacity from React Native. It enhances user experience by subtly changing opacity on press, making interactions feel more responsive. Compatible across all major platforms including Android, iOS, Web, macOS, Windows, and Linux, it integrates seamlessly into existing Flutter projects. The package is lightweight and designed for simplicity, focusing on intuitive touch feedback without additional complexity.

Use cases

  • Adding interactive feedback to buttons
  • Improving UX in mobile and web apps
  • Creating responsive UI elements
  • Enhancing accessibility through visual cues
  • Simplifying gesture handling in forms

Key features

  • Opacity-based press feedback
  • Cross-platform compatibility
  • Minimal setup required
  • Matches React Native's TouchableOpacity behavior
  • Lightweight and performant

Suitable for

  • Flutter developers familiar with React Native
  • Apps requiring consistent touch feedback
  • UI-heavy applications
  • Developers seeking simple gesture enhancements
  • Projects targeting multiple platforms

Considerations

  • Limited to opacity changes (no other animations)
  • Not suitable for complex gesture interactions
  • May require additional styling for custom effects
  • Depends on external source code repository
  • No built-in support for haptic feedback

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.

touchable_opacity

Version Build Status codecov

This package gives you access to the Touchableopacity widget. This widget uses the GestureDetector to allow interaction and animated to opacity of the widget on touch events.

Installing

Add the package to your pubspec.yaml file

dependencies:
	touchable_opacity: 1.2.0
Usage

Import the package using

import 'package:touchable_opacity/touchable_opacity.dart';

And simply use it as any other widget.

Container(
	child: TouchableOpacity(
		activeOpacity: 0.4,
		child: FlutterLogo(),
	),
),
Configuration

TouchableOpacity uses gestureDetector internally and tries to maintain all the different behaviours and interactions that gesture detector enables. To understand the different touch events that you can configure please visit the GestureDetector API docs here.

activeOpacity: double value that TouchableOpacity uses to animate the opacity of the child when a touch down event is received. The value must be between 1.0 and 0.0, the default value is 0.2 .

Example

The code found in the example folder of this repo shows how to use this package to render the content shown in the sample GIF. The folder contains a Flutter application that you can run yourself. Go here to jump into the code.

Support

If you have any issues with using this package, or have any ideas you thnk are good additions please create an issue here

Known Issues

Because of the way GestureDetector renders, TouchableOpacity fills its parent. If you want to bound the size to that of its child simply place the TouchableOpacity widget in any one of the Layout widgets, you can see a list of layout widgets available in flutter here

Categories

Source repository

Projects using this package