snacko 1.0.0
snacko: ^1.0.0 copied to clipboard
A lightweight, customizable, and modern Flutter snackbar package for building beautiful in-app notifications with smooth animations, flexible styling, and easy integration.
Snacko 🍿 #
A lightweight, customizable, and modern Flutter snackbar package. Build beautiful in-app notifications with smooth animations, glassmorphism effects, and native-feeling interactions.
✨ Features #
- 🚀 Overlay Authority: Uses Flutter's
Overlaysystem to stay visible over Dialogs, Bottom Sheets, and full-screen modals. - 🎨 Modern Aesthetics: Built-in Glassmorphism (blur) effects and vibrant, curated color palettes.
- 🖐️ Interactive: Swipe-to-dismiss support and support for custom action buttons.
- 📱 Adaptive: Automatically respects Safe Areas (notches/home indicators) and provides OS-specific default positions (Top for iOS, Bottom for Android).
- 💓 Tactile Feedback: Integrated haptic feedback for a premium native feel.
- ⏳ Progress Tracking: Subtle animated progress bar showing remaining duration.
- ⚡ Spring Physics: Organic, elastic animations for smooth entry and exit.
📦 Installation #
Add snacko to your pubspec.yaml:
dependencies:
snacko: ^0.0.1
Or run:
flutter pub add snacko
🚀 Quick Start #
import 'package:snacko/snacko.dart';
// Simple usage
Snacko.show(
context,
message: 'Profile updated successfully!',
type: SnackType.success,
);
🛠️ Detailed Usage & Use Cases #
1. Success Notification (with Title) #
Perfect for confirming user actions like form submissions or settings updates.
Snacko.show(
context,
title: 'Success!',
message: 'Your payment was processed securely.',
type: SnackType.success,
);
2. Error Alert (with Action) #
Use this for critical failures where the user might need to retry or see details.
Snacko.show(
context,
title: 'Upload Failed',
message: 'Could not connect to the server.',
type: SnackType.error,
actionLabel: 'RETRY',
onAction: () {
// Your retry logic here
},
);
3. Informational Update (Custom Duration) #
Great for non-critical background updates or new feature announcements.
Snacko.show(
context,
message: 'Syncing your library in the background...',
type: SnackType.info,
duration: 6000, // Display for 6 seconds
);
4. Warning (Custom Position) #
Use for temporary warnings like low battery or session expiry.
Snacko.show(
context,
message: 'Your session will expire in 5 minutes.',
type: SnackType.warning,
position: SnackPosition.top, // Force top position
);
📖 API Reference #
| Parameter | Type | Default | Description |
|---|---|---|---|
context |
BuildContext |
Required | Needed to find the app's Overlay. |
message |
String |
Required | The main notification text. |
title |
String? |
null |
Optional bold header text. |
type |
SnackType |
SnackType.info |
Visual style: success, error, warning, info. |
position |
SnackPosition? |
Adaptive |
top or bottom. Defaults to OS-specific best practice. |
duration |
int |
4000 |
Display duration in milliseconds. |
actionLabel |
String? |
null |
Text for an optional action button. |
onAction |
VoidCallback? |
null |
Callback function when action button is pressed. |
🛡️ Why Snacko? #
Traditional SnackBars in Flutter are tied to a Scaffold. This means they:
- Get hidden behind Dialogs or Bottom Sheets.
- Require a
Scaffoldeven if your screen doesn't have one. - Often look outdated without significant custom styling.
Snacko solves this by living in the Overlay. It is independent of the Scaffold and remains visible until dismissed, regardless of navigation changes or multi-layered UI.
🤝 Contributing #
Contributions are welcome! If you find a bug or have a feature request, please open an issue.
📄 License #
This project is licensed under the MIT License - see the LICENSE file for details.