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

A Flutter widget that provides shake animation and optional vibration effects, great for invalid forms, attention prompts, and user interaction feedback.

example/lib/main.dart

import 'package:awesome_shake_widget/enum/shake_preset.dart';
import 'package:awesome_shake_widget/shake_widget.dart';
import 'package:flutter/material.dart';
import 'package:shake_widget_example/widgets/custom_button.dart';
import 'package:shake_widget_example/widgets/custom_dialog.dart';
import 'package:shake_widget_example/widgets/custom_divider.dart';
import 'package:shake_widget_example/widgets/custom_form.dart';
import 'package:shake_widget_example/widgets/custome_network_image.dart';

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

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

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

class ShakeExamplePage extends StatelessWidget {
  final GlobalKey<ShakeWidgetState> lightKey = GlobalKey();
  final GlobalKey<ShakeWidgetState> mediumKey = GlobalKey();
  final GlobalKey<ShakeWidgetState> heavyKey = GlobalKey();
  final GlobalKey<ShakeWidgetState> customKey = GlobalKey();

  ShakeExamplePage({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('ShakeWidget Example')),
      body: Padding(
        padding: const EdgeInsets.all(16),
        child: SingleChildScrollView(
          child: Column(
            children: [
              ShakeWidget(
                key: lightKey,
                preset: ShakePreset.light,
                child: CustomButton(
                  onPressed: () => lightKey.currentState?.shake(),
                  text: "Light Shake",
                  icon: Icons.vibration,
                ),
              ),
              CustomDivider(text: "Medium Shake"),
              Text("This form will shake if any value is empty"),
              const SizedBox(height: 15),
              ShakeWidget(
                key: mediumKey,
                preset: ShakePreset.medium,
                child: Padding(
                  padding: const EdgeInsets.symmetric(horizontal: 40.0),
                  child: CustomForm(
                    onEmpty: (first, second) => mediumKey.currentState?.shake(),
                  ),
                ),
              ),
              CustomDivider(text: "Heavy Shake"),
              Text("Image will shake on load finished"),
              const SizedBox(height: 15),
              ShakeWidget(
                key: heavyKey,
                preset: ShakePreset.heavy,
                child: CustomNetworkImage(
                  onLoaded: () => heavyKey.currentState?.shake(),
                ),
              ),
              CustomDivider(text: "Custom Shake"),
              CustomButton(
                onPressed: () => showCustomDialog(context: context),
                text: 'Trigger Heavy Shake',
              ),
            ],
          ),
        ),
      ),
    );
  }
}
7
likes
160
points
39
downloads

Publisher

unverified uploader

Weekly Downloads

A Flutter widget that provides shake animation and optional vibration effects, great for invalid forms, attention prompts, and user interaction feedback.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, vibration

More

Packages that depend on awesome_shake_widget