How atanu-sabyasachi/snackify works
This repository is a Flutter package, not a standalone app. Its architecture is centered around a single public API for showing highly customizable SnackBars, with the rest of the library providing configuration, rendering, lifecycle, and optional text-to-speech behavior.
1. Public entrypoint
- lib/snackify.dart is the main facade the consumer imports.
- The README shows the core usage pattern: Snackify.show(...).
- This file likely re-exports the package types and presents the stable surface area.
2. Snack display pipeline
- The main flow starts when client code calls Snackify.show(context, ...).
- The call is translated into a visual snack overlay, with parameters such as type, title/subtitle, duration, position, animation timing, shadows, and persistence.
- The package is responsible for mounting and removing the snack independently of a standard ScaffoldMessenger-only approach.
3. Overlay-based presentation layer
- lib/overlay_entry.dart suggests the snackbar is injected via Flutter overlays.
- This is the boundary that attaches the snack UI to the current screen and controls visibility/dismissal.
- This design allows top/bottom positioning, persistent display, and animated entrance/exit without requiring a dedicated page or route.
4. Snack UI rendering
- lib/snackify_snackbar.dart likely contains the actual widget tree for the snackbar card/banner.
- This is where the title, subtitle, action widget, close affordance, background gradient, border radius, shadows, and layout rules are assembled.
- It is the main visual component that consumers experience.
5. Type-driven styling system
- lib/enums/snack_enums.dart defines core enum concepts such as SnackType and SnackPosition.
- lib/snack_type_details.dart and lib/snacktype_configuration.dart model the defaults and overrides for each snack type.
- The architecture uses type as a styling and behavior selector, so success, error, warning, info, and custom each map to a distinct visual configuration.
6. Configuration as data, not code
- SnackTypeConfiguration lets callers override colors, icon, text style, margins, elevation, and border radius.
- TTSConfiguration packages speech-related settings such as speakOnShow, language, speech rate, and pitch.
- This keeps the rendering logic mostly declarative: the UI is built from configuration objects rather than ad hoc branching in application code.
7. Initialization and defaults
- lib/initializers.dart likely contains helper logic for normalizing parameters, applying defaults, and building the final snack configuration.
- This is an important boundary between the API layer and the rendering layer: user inputs are resolved here before the overlay widget is created.
- It is also where defaults for duration, animation, and fallback visuals probably converge.
8. Text-to-speech side effect path
- TTS is an optional side effect triggered when a snack is shown.
- The flow is separate from the visual snack rendering: the snack appears, and the message may be spoken based on TTSConfiguration.
- This makes TTS an auxiliary subsystem attached to the show lifecycle rather than part of the UI tree itself.
9. Consumer-facing example and verification
- example/main.dart is a usage sample that demonstrates the package in a real Flutter app context.
- test/snackify_test.dart provides a minimal verification boundary for the public API and expected behavior.
- These two pieces show the intended integration contract without adding runtime complexity to the package itself.
10. Assets and documentation
- assets/images and assets/snack_images are documentation/demo assets used in the README.
- They support the package’s visual identity and examples, but they are not part of the runtime control flow.
- The README acts as the primary integration documentation for consumers.
11. Overall architectural shape
- The package is a small layered system: API facade → config normalization → overlay lifecycle → snackbar widget rendering → optional TTS side effect.
- The boundaries are cleanly separated between “what the caller wants” and “how Flutter displays it.”
- For an architecture diagram, the most important nodes are the Snackify.show() entrypoint, the overlay controller, the snackbar widget, the type/config model, and the TTS path.
Main entry points: initializers.dart Initializers · snackify_snackbar.dart Snack UI · snackify.dart Snackify · README.md README
Components 15
Public API
Stable import surface and consumer entrypoint
- Snackify · Main public entrypoint exported by the package
lib/snackify.dart
Core Flow
Show call normalization and orchestration
- Initializers · Builds final snack settings and applies defaults
lib/initializers.dart - Show API · The show-call path exposed to consumers
Presentation
Overlay attachment and snack rendering
- Overlay Entry · Attaches and removes snack UI in Flutter overlay space
lib/overlay_entry.dart - Snack UI · Renders the snackbar card, layout, and affordances
lib/snackify_snackbar.dart
Configuration
Type-driven defaults and overrides
- Snack Enums · Core enums for type, position, and related choices
lib/enums/snack_enums.dart - Type Details · Default visuals and behavior for each snack type
lib/snack_type_details.dart - Snack Config · User overrides for color, icon, layout, and motion
lib/snacktype_configuration.dart - TTS Config · Options for optional text-to-speech behavior
lib/tts_config.dart
Auxiliary
Optional side effects and usage surface
- TTS Path · Optional speech triggered alongside snack display
- Example App · Consumer-facing integration example
example/main.dart - Tests · Minimal public API and behavior checks
test/snackify_test.dart - README · Primary integration and usage documentation
README.md - Images · Documentation and demo image assets
assets/images - Snack Images · Package imagery used in docs and demos
assets/snack_images
Connections 18
- Snackify → Show API: exposes · Stable facade forwards consumer calls
- Show API → Initializers: normalizes · Resolves defaults and final configuration
- Initializers → Snack Enums: uses · Interprets type and position choices
- Initializers → Type Details: applies · Maps snack type to default presentation details
- Initializers → Snack Config: merges · Combines caller overrides into final config
- Initializers → TTS Config: includes · Carries optional speech settings
- Show API → Overlay Entry: launches · Creates overlay-backed snack lifecycle
- Overlay Entry → Snack UI: hosts · Places the rendered snack widget into overlay
- Overlay Entry → TTS Path: triggers · Starts optional speech when show is invoked
- TTS Path → TTS Config: reads · Uses speech settings to control playback
- Snack UI → Snack Enums: styles by · Adapts visuals to snack type and placement
- Snack UI → Type Details: renders from · Uses type defaults for colors, icons, and emphasis
- Snack UI → Snack Config: overrides · Applies caller-supplied appearance settings
- Example App → Snackify: imports · Demonstrates package usage in an app
- Tests → Snackify: verifies · Checks public API behavior
- README → Snackify: documents · Shows the primary usage contract
- README → Images: references · Uses documentation images
- README → Snack Images: references · Uses package imagery in docs