awesome_shake_widget 1.0.1 copy "awesome_shake_widget: ^1.0.1" to clipboard
awesome_shake_widget: ^1.0.1 copied to clipboard

A Widget to add shake and vibrate functionality.

๐Ÿš€ awesome_shake_widget #

A customizable Flutter widget that adds shake animations with haptic and vibration feedback. Perfect for invalid forms, error indicators, or drawing attention to UI components.

Pub Version Platform License


โœจ Features #

  • Shake any widget on demand
  • Built-in presets: light, medium, heavy
  • Optional vibration (custom or haptic)
  • Fully customizable offset, pattern & intensities
  • Easy to trigger using a GlobalKey

๐Ÿ“ฆ Installation #

dependencies:
  awesome_shake_widget: ^1.0.1

Run:

flutter pub get

๐Ÿงช Usage #

1๏ธโƒฃ Standard (Shake + Vibration) #

final shakeKey = GlobalKey<ShakeWidgetState>();

ShakeWidget(
  key: shakeKey,
  preset: ShakePreset.medium,
  child: Text("Tap Me"),
);

// Somewhere else, e.g., on button press:
shakeKey.currentState?.shake();

2๏ธโƒฃ Shake Only (No Vibration) #

ShakeWidget(
  key: shakeKey,
  preset: ShakePreset.custom,
  customConfig: ShakeConfig(
    offset: 20,
    vibrationType: VibrationType.none,
  ),
  child: Icon(Icons.info),
);

3๏ธโƒฃ Full Custom (Offset + Pattern + Intensities) #

ShakeWidget(
  key: shakeKey,
  preset: ShakePreset.custom,
  customConfig: ShakeConfig(
    offset: 32,
    pattern: [0, 50, 100, 50],
    intensities: [255, 0, 255, 0],
    vibrationType: VibrationType.custom,
  ),
  child: Text("Custom Shake!"),
);

Trigger it via:

shakeKey.currentState?.shake();

๐Ÿงฉ API Reference #

Enum: ShakePreset #

Value Offset Vibration
light 8 Haptic
medium 16 Haptic
heavy 24 Patterned Vibe
custom User-defined Custom

Enum: VibrationType #

  • none โ€“ no vibration
  • haptic โ€“ system haptic feedback
  • custom โ€“ vibration with pattern/intensity (Android only)

ShakeConfig #

ShakeConfig({
  required double offset,
  List<int>? pattern,
  List<int>? intensities,
  VibrationType vibrationType = VibrationType.haptic,
});

๐Ÿ’ก Example App #

Clone and run the example:

cd example
flutter run

Example main.dart:

import 'package:flutter/material.dart';
import 'package:awesome_shake_widget/shake_widget.dart';

void main() => runApp(const MyApp());

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: ShakeDemo(),
    );
  }
}

class ShakeDemo extends StatelessWidget {
  final shakeKey = GlobalKey<ShakeWidgetState>();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('Shake Demo')),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            ShakeWidget(
              key: shakeKey,
              preset: ShakePreset.heavy,
              child: const Icon(Icons.warning, size: 64),
            ),
            const SizedBox(height: 32),
            ElevatedButton(
              onPressed: () => shakeKey.currentState?.shake(),
              child: const Text("Shake it!"),
            ),
          ],
        ),
      ),
    );
  }
}

๐Ÿ“„ License #

MIT ยฉ Juanma Del Boca

12
likes
0
points
33
downloads

Publisher

unverified uploader

Weekly Downloads

A Widget to add shake and vibrate functionality.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, vibration

More

Packages that depend on awesome_shake_widget

Packages that implement awesome_shake_widget