anchor_toast 0.2.0
anchor_toast: ^0.2.0 copied to clipboard
A Flutter package for displaying contextual toasts anchored to widgets with smart positioning and smooth animations.
Changelog #
0.2.0 #
Added #
- Customizable Screen Padding: New
screenPaddingparameter inshowToast()method allows control over screen edge padding- Default value remains 16.0 pixels for backward compatibility
- Controls minimum distance between toast and screen edges
- Affects toast positioning and maximum width calculations
- Applies to both automatic positioning and manual position updates during scrolling
Improved #
- Enhanced Keyboard-Aware Positioning: Comprehensive keyboard and view insets handling for optimal toast placement
- Real-time Keyboard Tracking: Automatic repositioning when keyboard appears/disappears using view insets monitoring
- Vertical Bounds Checking: Toasts are automatically clamped within safe screen bounds considering keyboard height
- Unified Position Calculation: Single positioning logic ensures consistency between initial placement and dynamic updates
- Optimized ValueNotifier Lifecycle: Position notifier is now reused across multiple toasts for better memory efficiency
Fixed #
- Null Safety Improvements: Removed all null assertion operators (
!) and replaced with safe null-checking patterns - Position Calculation Consistency: Unified the initial toast positioning and scroll-based repositioning logic to prevent discrepancies
- Memory Optimization: Position notifier is no longer recreated for each toast, reducing garbage collection overhead
0.1.0 #
Added #
- Manual Position Override: New
showAboveparameter inshowToast()method allows manual control over toast positioning- Set
showAbove: trueto force toast above the anchor - Set
showAbove: falseto force toast below the anchor - Set
showAbove: null(default) to use automatic smart positioning
- Set
Improved #
- Keyboard-Aware Positioning: Smart positioning now considers view insets (keyboard, system UI) for better toast placement
- Automatically accounts for keyboard height when calculating available space
- Uses visible screen area center instead of full screen center when keyboard is shown
- Ensures toasts remain visible and accessible when keyboard or other system UI is active
0.0.1 #
Initial Release #
- AnchorToast Widget: Wrap any anchor widget to enable toast functionality
- AnchorToastController: Complete controller for managing toast display and dismissal
- Smart Positioning: Automatically determines optimal position (above/below) based on available screen space
- Smooth Animations: Beautiful scale and opacity animations with optimized timing
- Auto-dismiss: Configurable duration for automatic toast dismissal
- Manual Dismiss:
dismiss()method for manual toast control - Overlay Integration: Uses Flutter's Overlay system for proper z-index handling
- Customizable Offset: Adjustable spacing between anchor and toast
- Memory Management: Proper disposal of resources and animation controllers
Features #
- Smart positioning above/below anchor based on available space
- Scale and opacity animations with smooth curves
- Auto-dismiss with configurable duration
- Manual dismiss capability
- Clean and simple API with
AnchorToastwidget and controller - Proper memory management and cleanup
- Comprehensive test coverage
- Example app with various use cases
- Full documentation and API reference