搜尋套件、儲存庫與 APP 分類

touchable_opacity 封面
套件詳情v1.2.0

touchable_opacity

此組件讓您在使用者與您的應用程式互動時提供更直覺的回饋,類似於 React Native 中的 TouchableOpacity。

AndroidiOSWebmacOSWindowsLinux
近 30 天下載
7000
喜歡數
17
Pub 分數
140

安裝套件

flutter pub add touchable_opacity

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

touchable_opacity 套件提供了一個 Flutter 小組件,當使用者與 UI 元素互動時會提供視覺反饋,模擬 React Native 中 TouchableOpacity 的行為。透過按壓時微妙地改變不透明度,提升使用者體驗,讓互動感覺更為回應迅速。此套件相容於所有主要平台,包含 Android、iOS、Web、macOS、Windows 與 Linux,能順暢整合至現有的 Flutter 專案中。該套件輕量且設計簡潔,專注於直覺的觸控反饋,不增加額外複雜性。

適用情境

  • 為按鈕新增互動反饋
  • 提升行動與網頁應用的使用者體驗
  • 建立響應式 UI 元素
  • 透過視覺提示增強可存取性
  • 簡化表單中的觸控操作處理

主要特色

  • 基於不透明度的按壓回饋
  • 跨平台相容性
  • 所需的設定最少
  • 符合 React Native 的 TouchableOpacity 行為
  • 輕量且高效

適合對象

  • 熟悉 React Native 的 Flutter 開發人員
  • 需要一致觸控反饋的應用程式
  • 以UI為主的應用程式
  • 尋求簡單觸控增強功能的開發者
  • 針對多個平台的專案

使用建議

  • 僅限透明度變更(無其他動畫)
  • 不適合複雜的手勢互動
  • 可能需要額外的樣式設定以實現自訂效果
  • 依賴外部原始碼倉儲
  • 無內建的觸覺反饋支援

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

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

所屬分類

原始碼儲存庫

使用此套件的專案