flutter_watermark_plus 1.0.0
flutter_watermark_plus: ^1.0.0 copied to clipboard
A Flutter package for adding watermarks to widgets with customizable text, positioning, and styling options..
Flutter Watermark Plus #
A Flutter package that provides watermark functionality for images and widgets with customizable properties.
Features #
- Cross-platform support: Works on both Android and iOS
- Widget-based watermarks: Add watermarks to any Flutter widget
- Image-based watermarks: Apply watermarks directly to images
- Customizable properties: Text style, rotation, opacity, positioning, and spacing
- Consistent behavior: Shared drawing logic ensures consistent results across different use cases
Architecture #
The package has been refactored to eliminate code duplication and improve maintainability:
Core Components #
Config: Configuration class for watermark propertiesTextWatermarkWidget: Widget for adding watermarks to Flutter widgetsCanvasWatermarkEngine: Engine for applying watermarks to imagesWatermarkPainterUtil: Shared utility for drawing watermark patternsWatermarkProcessor: High-level processor for image watermark operations
Code Refactoring Benefits #
-
Eliminated Duplication: The watermark drawing logic was duplicated between
watermark_widget.dartandcanvas_watermark_engine.dart. Now both use the sharedWatermarkPainterUtil. -
Consistent Behavior: Both widget-based and image-based watermarks now use the same drawing logic, ensuring consistent results.
-
Better Maintainability: Changes to watermark drawing logic only need to be made in one place.
-
Clear Separation: Each component has a single responsibility:
Config: Configuration managementTextWatermarkWidget: Widget renderingCanvasWatermarkEngine: Image processingWatermarkPainterUtil: Drawing logicWatermarkProcessor: High-level operations
Configuration Options #
textStyle: Text appearance (color, font size, weight, etc.)rotationAngle: Rotation in radianshorizontalInterval: Horizontal spacing between watermarksverticalInterval: Vertical spacing between watermarksoffset: Position offset from top-left cornerbackgroundColor: Background color of watermark areatextAlign: Text alignmenttextDirection: Text direction (LTR/RTL)locale: Locale for text rendering
Examples #
See the example/ folder for complete demonstrations:
flutter_watermark_plus_example.dart: Widget-based watermark exampleswatermark_processor_example.dart: Image processing watermark examples