s_bounceable

A Flutter package providing a bounceable widget with intelligent single and double tap detection, built on top of flutter_bounceable.

pub package License: MIT

Features

Smooth Bounce Animation - Provides satisfying visual feedback using scale animations

👆 Smart Tap Detection - Intelligently distinguishes between single and double taps

⚙️ Customizable - Configure scale factor to match your design requirements

🎯 Easy to Use - Simple API that wraps any Flutter widget

🧪 Well Tested - Comprehensive test coverage for reliable behavior

Demo

Demo

Installation

Add this to your package's pubspec.yaml file:

dependencies:
  s_bounceable: ^2.0.0

Then run:

flutter pub get

Usage

Basic Example

Import the package:

import 'package:s_bounceable/s_bounceable.dart';

Wrap any widget with SBounceable:

SBounceable(
  onTap: () {
    debugPrint('Single tap!');
  },
  onDoubleTap: () {
    debugPrint('Double tap!');
  },
  child: Container(
    padding: const EdgeInsets.all(24.0),
    decoration: BoxDecoration(
      color: Colors.blue,
      borderRadius: BorderRadius.circular(12),
    ),
    child: const Text(
      'Tap or Double Tap Me',
      style: TextStyle(color: Colors.white, fontSize: 18),
    ),
  ),
)

Custom Scale Factor

Adjust the bounce intensity:

SBounceable(
  onTap: () => print('Tapped'),
  scaleFactor: 0.90, // More pronounced bounce (default is 0.95)
  child: YourWidget(),
)

Single Tap Only

SBounceable(
  onTap: () => print('Tapped'),
  child: YourWidget(),
)

Double Tap Only

SBounceable(
  onDoubleTap: () => print('Double tapped'),
  child: YourWidget(),
)

Complete Example

See the full working example in the example directory:

import 'package:flutter/material.dart';
import 'package:s_bounceable/s_bounceable.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: const Text('SBounceable Example')),
        body: Center(
          child: SBounceable(
            onTap: () {
              debugPrint('Single tap!');
            },
            onDoubleTap: () {
              debugPrint('Double tap!');
            },
            child: Container(
              padding: const EdgeInsets.all(24.0),
              decoration: BoxDecoration(
                color: Colors.blue,
                borderRadius: BorderRadius.circular(12),
              ),
              child: const Text(
                'Tap or Double Tap Me',
                style: TextStyle(color: Colors.white, fontSize: 18),
              ),
            ),
          ),
        ),
      ),
    );
  }
}

How It Works

The SBounceable widget uses a smart tap detection algorithm:

  • Double Tap Threshold: 300ms window to detect double taps
  • Single Tap Delay: Waits for the threshold period before executing single tap to avoid false triggers
  • Triple Tap Prevention: Resets state after double tap to prevent unintended triple taps

API Reference

SBounceable

Parameter Type Required Default Description
child Widget Yes - The widget to make bounceable
onTap VoidCallback? No null Callback for single tap
onDoubleTap VoidCallback? No null Callback for double tap
scaleFactor double? No 0.95 Scale factor for bounce effect (0.0 to 1.0)

Dependencies

This package depends on:

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Author

Christophe Chanteur

Repository

https://github.com/SoundSliced/s_bounceable

Issues

Please file issues at: https://github.com/SoundSliced/s_bounceable/issues

Libraries

s_bounceable
s_bounceable package