搜索插件、代码仓与 APP 分类

GitHub 代码仓juanmadelboca/awesome_shake_widget

awesome_shake_widget

juanmadelboca/awesome_shake_widget open-source repository details.

awesome_shake_widget 项目封面
星标
6
复刻
0
最近推送(UTC)
2026年4月1日
项目状态
未归档

原始 README

以下为英文项目原文快照,最新内容请访问 GitHub。

🚀 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)

By using the built-in presets — light, medium, heavy and custom — you can quickly apply different vibration intensities and patterns, perfectly paired with UI shake animations for a dynamic and responsive user experience.

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)

If you only want the visual shake effect without vibration, you can set vibrationType to VibrationType.none using the ShakeConfig. To customize the intensity of the shake, adjust the offset value — higher values will produce a stronger visual effect.

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

3️⃣ Advanced Configuration: Full Control Over Visual and Vibration Effects

You can also create custom vibration patterns by setting vibrationType to VibrationType.custom, and providing your own pattern and intensities. This gives you full control over the vibration behavior.

ShakeWidget(
key: shakeKey,
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();

🎥 Demo

This demo shows how you can apply shake animations to:

  • ✅ Buttons
  • 💬 Dialogs
  • 🖼️ Images
  • ✏️ Text fields
  • 📦 Any widget

🧩 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

Juanma Del Boca GitHub avatar
GitHub 作者

Juanma Del Boca ↗

🚀 Flutter Developer | 3 Apps on Play Store 🤝 Passionate about open source & developer communities 📬 Open to collabs on Flutter packages & mobile tools

语言DartRubyKotlinSwiftJavaObjective-C

此仓库发布的插件

使用的依赖

依赖清单 4 项

  • flutter{"sdk":"flutter"}
  • vibration^3.1.8
  • flutter_test开发依赖{"sdk":"flutter"}
  • flutter_lints开发依赖^6.0.0

如何选择适合项目的代码仓?

先按使用场景筛选,再比较项目活跃情况,最后到原始仓库核对使用要求。

  1. 通过仓库名、作者或描述搜索,再按技术分类缩小范围。
  2. 结合星标、复刻与最近推送比较项目;星标反映社区关注,不代表质量保证。
  3. 使用前在 GitHub 核对 README、许可证与 Issues。

来源与维护

“A repository is the most basic element of GitHub.”

GitHub Docs — About repositories ↗