flutter_screenutil_plus 1.4.0
flutter_screenutil_plus: ^1.4.0 copied to clipboard
A powerful Flutter plugin for adaptive screen and font scaling with CSS-like breakpoints and SwiftUI-style size classes. Includes responsive scaling and breakpoint-aware widgets.
Changelog #
All notable changes to this project will be documented in this file.
1.4.0 - 2025-12-23 #
Added #
-
InheritedWidget-Based Scope: Introduced
ScreenUtilPlusScopefor efficient, targeted rebuilds- New
autoRebuildparameter inScreenUtilPlusInit(defaults totruefor backward compatibility) - When
autoRebuild: false, only widgets that explicitly depend onScreenUtilPlusScoperebuild - Significantly improves performance by avoiding unnecessary tree-wide rebuilds
- Accessible via
ScreenUtilPlus.of(context)orcontext.su
- New
-
Context-Aware Extensions: New
ResponsiveSizeContextextension onBuildContextcontext.w(value)- Scale widthcontext.h(value)- Scale heightcontext.r(value)- Scale radiuscontext.sp(value)- Scale font sizecontext.spMin(value)- Scale font size with minimumcontext.dg(value)- Scale diagonalcontext.dm(value)- Scale diametercontext.verticalSpace(value)- Create vertical spacingcontext.horizontalSpace(value)- Create horizontal spacingcontext.edgeInsets(...)- Create scaled EdgeInsetscontext.borderRadius(...)- Create scaled BorderRadius- These extensions work efficiently with
autoRebuild: falseby registering InheritedWidget dependencies
-
Example App Enhancements:
- New
ScopeDemoPageshowcasingScreenUtilPlusScopefeatures and performance benefits - Interactive demo comparing rebuild behavior with
autoRebuildon/off - Visual demonstrations of context-aware extensions
- New
-
Comprehensive Test Coverage:
- Added 25+ new tests across 6 new test files
- Achieved 99.2% code coverage (1574/1586 lines) with 619 total tests
- New test files:
screen_util_plus_scope_test.dart- InheritedWidget functionalityresponsive_size_context_test.dart- Context-aware extensionscontext_extension_test.dart- Context extension methodsadaptive_text_style_test.dart- Adaptive text styles including xxl breakpointscreen_util_plus_desktop_test.dart- Desktop platform supportscreen_util_plus_edge_cases_test.dart- Edge case scenarios
Changed #
-
Simplified Context Extension: Refactored
mediaQueryDatagetter inScreenUtilContextExtension- Removed unreachable
View.maybeOffallback for cleaner code - Now simply returns
MediaQuery.maybeOf(this) - Achieved 100% test coverage for this file
- Removed unreachable
-
R-Widgets Enhancement: Updated
RContainerandRTextto be context-aware- Now use
context.suto register InheritedWidget dependencies - Benefit from efficient rebuilds when
autoRebuild: false
- Now use
-
Code Quality Improvements:
- Removed unused imports across multiple files
- Added explicit braces to single-line if statements for better readability
- Improved code formatting and consistency
Performance #
-
Rebuild Optimization: With
autoRebuild: false, only widgets that explicitly use:ScreenUtilPlus.of(context)orcontext.su- Context-aware extensions (
context.w(),context.h(), etc.) - R-widgets (
RContainer,RText, etc.)
will rebuild when screen metrics change, significantly reducing unnecessary rebuilds
Migration Guide #
For existing users, no changes are required. The default behavior (autoRebuild: true) maintains backward compatibility.
To opt into the new performance optimizations:
- Set
autoRebuild: falseinScreenUtilPlusInit - Use context-aware extensions (
context.w()) instead of num extensions (100.w) - Or use R-widgets (
RContainer,RText) which are already context-aware
See the new ScopeDemoPage in the example app for a complete demonstration.
1.3.1 - 2025-12-10 #
Changed #
- Refactoring: Core logic improvements for better maintainability and performance.
- Simplified
ScreenUtilPlussingleton and initialization logic. - Optimized
AdaptiveContainerproperty handling.
- Simplified
- Robustness: Improved
ScreenUtilPlusInitto robustly handle nestedMediaQuerydata, falling back toView.maybeOfonly when necessary.
Added #
- Tests: Added dedicated tests for initialization fallback logic to ensure correct behavior in various widget tree configurations.
1.3.0 - 2025-12-07 #
Added #
- Default Initialization:
ScreenUtilPlusfields now initialize with default values (defaultSizeof 360x690) instead of empty/zero values, preventing issues when accessed before explicit configuration. - Optional Configuration:
designSizeparameter ininit,configure, andScreenUtilPlusInitis now optional, defaulting to 360x690. This allows for simpler setup when using standard defaults.
1.2.2 - 2025-12-07 #
Changed #
- Revert:
designSizeparameter inScreenUtilPlus.initandScreenUtilPlusInitis now required again. The previous change to make it optional was reverted to ensure explicit configuration.
Fixed #
- Crash Fix: Fixed
LateInitializationErrorinScreenUtilPlus.configurewhen called with null parameters before initialization. Added default values for internal flags to prevent this crash.
1.2.1 - 2025-12-03 #
Added #
- Comprehensive Test Suite: Added extensive test coverage for all new features
- Unit tests for
AdaptiveValuesclass (100% coverage) - Unit tests for
AdaptiveContainerandSimpleAdaptiveContainerwidgets (94.7% coverage) - Unit tests for
Breakpointsclass (95% coverage) - Unit tests for
ResponsiveQueryclass (100% coverage) - Additional tests for
SizeClassBuilderandConditionalBuilderwidgets - Achieved 98.3% overall code coverage with 500+ tests
- Unit tests for
Changed #
- Documentation: Comprehensive pub.dev documentation update
- Complete README.md rewrite with all features documented
- Added CSS-like breakpoints documentation section
- Added SwiftUI-like size classes documentation section
- Added adaptive widgets documentation with examples
- Added API reference tables
- Added best practices guide
- Enhanced package description in
pubspec.yaml
Fixed #
- Fixed test failures in
AdaptiveContainertests by properly handling.wand.hscaling - Fixed
SizeClassBuildertest to use appropriate screen sizes for compact/regular detection - Fixed padding fallback behavior in
AdaptiveValuestests to match actual implementation
1.2.0 - 2025-12-02 #
Added #
-
CSS-like Breakpoints System: Added comprehensive breakpoint system with predefined sets (Bootstrap, Tailwind, Material Design, Mobile-first)
Breakpointsclass with configurable breakpoint valuesBreakpointenum (xs, sm, md, lg, xl, xxl)- Context extensions for easy breakpoint checking (
context.breakpoint,context.isAtLeast(), etc.) - Breakpoint comparison methods (
isAtLeast(),isLessThan(),isBetween(),isExactly())
-
SwiftUI-like Size Classes: Added size class system for adaptive layouts
SizeClassenum (compact, regular) for horizontal and vertical dimensionsSizeClassesclass with helper methods- Context extensions (
context.sizeClasses,context.horizontalSizeClass, etc.) - Customizable threshold for size class determination
-
Responsive Query Utilities: Added utilities for responsive design queries
ResponsiveQueryclass for breakpoint-based value selectionAdaptiveValuesclass for responsive sizing with breakpoints (width, height, fontSize, radius, padding, margin)- Context extensions for convenient access
- Value selection with automatic fallback to larger/smaller breakpoints
-
Adaptive Text Styles: Added extensions for creating adaptive text styles
AdaptiveTextStyleExtensiononBuildContextfor breakpoint-based text stylesTextStyleExtensiononTextStylewith responsive methods (.r,withLineHeight(),withAutoLineHeight(),withLineHeightFromFigma())
-
Adaptive Widgets: Added new responsive widgets
AdaptiveContainerandSimpleAdaptiveContainer- Containers that adapt properties based on breakpointsAdaptiveText- Text widget that adapts style properties based on breakpointsResponsiveBuilder- Builder widget for different breakpoints with fallback chainSizeClassBuilder- Builder widget for size classes (compact/regular, horizontal/vertical)ConditionalBuilder- Conditional rendering based on breakpoint conditions
-
Comprehensive Test Coverage: Added extensive test suite
- Integration tests for all adaptive features
- Unit tests for breakpoints, size classes, responsive queries, and adaptive values
- Widget tests for all adaptive widgets
- 98.3% code coverage with 500+ tests
-
Documentation: Comprehensive pub.dev documentation
- Complete README with all features documented
- API reference tables
- Usage examples for all features
- Best practices guide
Changed #
- Updated
ResponsiveThemeto use newTextStyleExtension.rfor responsive text styles - Enhanced
RTextwidget with improved responsive text handling - Improved package description in
pubspec.yamlto highlight new features - Enhanced library documentation comments for better API documentation on pub.dev
Fixed #
- Fixed test failures in adaptive container tests by properly handling scaling
- Fixed size class builder test to use appropriate screen sizes
- Fixed padding fallback behavior in adaptive values tests
1.1.1 2025 #
Added #
- Implemented change detection for screen metrics using Equatable to optimize rebuilds
- Added
_ScreenMetricsclass with value-based equality comparison for efficient configuration change detection
Changed #
- Optimized rebuild behavior: registered elements now only rebuild when screen metrics or fontSizeResolver actually change
- Improved performance by preventing unnecessary rebuilds when configuration remains functionally identical
1.1.0 2025 #
Added #
- New
ScreenUtilModebehavior refactor with responsive rebuilding improvements - Additional unit tests covering new utilities, rebuild flow, and registerToBuild edge cases
Changed #
- Refactored
ScreenUtilPlusInitto reduce duplication and improve responsiveness - Extracted
DeviceTypeenum andMediaQueryDataextension into dedicated utility files - Improved
ScreenUtilPlus.configureerror handling and rebuilt element management
1.0.2 2025 #
Added #
- Comprehensive example app demonstrating all package features
- Library-level documentation with usage examples
- Documentation for
BorderRadiusExtensionand its methods (.r,.w,.h) - Documentation for
BoxConstraintsExtensionand its methods (.r,.hw,.w,.h) - Example directory with complete working demo
Changed #
- Improved pub.dev score with complete API documentation
1.0.1 2025 #
Changed #
- Reorganized package structure for better maintainability
- Improved folder organization with logical subdirectories (core, widgets, extensions, mixins, utils, internal)
1.0.0 2025 #
Added #
- Comprehensive unit test coverage (114+ tests)
- Fixed deprecation warning: replaced
textScaleFactorwithtextScaler.scale(1.0) - Improved error handling for defunct elements in
configuremethod
Fixed #
- Fixed assertion error when trying to rebuild defunct elements
- Fixed
spextension test by properly handling fontSizeResolver