screen_size_adapter 1.0.0
screen_size_adapter: ^1.0.0 copied to clipboard
Binding-level screen-size adapter for Flutter with per-view configuration.
Changelog #
All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
1.0.0 - 2026-07-15 #
BREAKING: This is the single public upgrade from pub.dev
0.2.0to the config-first, binding-level API. All unreleased work since0.2.0is consolidated into this one public version.
Added #
ScreenSizeAdapterConfigis the complete, per-view configuration object for design size, scale axis, desktop behavior, and scale bounds.- Experimental per-view registry APIs for host-created secondary views:
attachView,updateView,detachView,resetView,scaleForView, andconfigForViewoperate onFlutterViewinstances. ScaleAxis(width,height,shorter,longer) selects the scale calculation strategy.ScreenSizeAdapterScopesupplies correctedMediaQuerydata for explicit non-primaryViewsubtrees. The defaultrunAppview is wrapped automatically.ScreenSizeAdapter.originSizeOf(context)exposes the unscaled native logical size for responsive breakpoints.ScreenSizeAdapter.setDesignSize,reset,scaleOf, andcomputeScaleprovide context-based runtime controls and testable scale math.ScreenSizeTestEnvironmentsupports widget tests that cannot install the production binding at the MediaQuery-only fidelity level.ScreenSizeTestViewportadditionally gives a wrapped test subtree tight adapted layout constraints without claimingRenderView, root hit-testing, or production pointer-converter fidelity.ScreenSizeWidgetsFlutterBinding.instanceis the typed binding accessor for integration code.
Changed #
- BREAKING:
ScreenSizeWidgetsFlutterBinding.ensureInitializednow takes oneScreenSizeAdapterConfiginstead of a design size plus compatibility parameters. - BREAKING:
attachViewandupdateViewnow take a completeScreenSizeAdapterConfig; public view inspection usesFlutterViewrather than raw view IDs. - BREAKING: Adaptation is performed through each view's
ViewConfiguration.devicePixelRatio, so widgets use plain design-unit numbers. - BREAKING: Removed the old widget-wrapper/singleton model, including
ScreenSizeWidget,ScreenSizeHelper,DesignSizeInheritedWidget,ScreenSizeTextScaleMode, andScreenSizeAdapter.of/maybeOf. - BREAKING: Removed bare-number and geometry extensions such as
.dp,.sp,.sw,.w,.r,verticalSpace, andhorizontalSpace. ScreenSizeAdapterConfig.maxScalenow defaults tonull; pass an explicit cap when an application needs one.copyWithcan clear nullable scale bounds withclearMinScaleandclearMaxScale.ScaleAxis.widthno longer swaps axes implicitly in landscape; chooseScaleAxis.shorterwhen aspect-safe scaling is required.- Minimum supported Flutter is now
3.29.2. - The stable support boundary is the implicit-view
runApppath. Same-engine secondary-view registration and scoping remain experimental and require host-level verification withtool/verification/desktop_multi_view.md. - Automatic registration now targets only
PlatformDispatcher.implicitView. When no implicit view exists, every host-created view requires explicitattachViewregistration.
Fixed #
MediaQuerynow consistently followsMediaQuery.size = originSize / scaleand scales device pixel ratio, padding, view padding, view insets, and system gesture insets. Without clamping only the selected axis aligns with the design size; scale bounds can make neither dimension align.- Pointer packets use the registered view's effective device pixel ratio.
- Gesture touch slop and display-feature bounds use the same design-unit coordinate system as pointer events and layout.
ScreenSizeAdapter.resetclears scale bounds so it always restores native1.0scaling.- Runtime updates that cross
scale == 1.0preserve the wrapped application subtree instead of recreating its state. - The copy-paste orientation example now rejects stale callbacks and equivalent design-size updates instead of sending a redundant metrics notification.
- The example's automatic design-size swap now follows viewport orientation even when its controls are inside a vertical scroller.
- Invalid design sizes and scale bounds, including non-finite values and a
minScalegreater thanmaxScale, fail fast before registry updates. - README initialization order, coordinate wording, and strictly verified Dart snippets now match the runtime contract.
Migration #
- Replace
ensureInitialized(size, config: ...)withensureInitialized(ScreenSizeAdapterConfig(...)). - Replace
attachViewandupdateViewparameter lists withconfig: ScreenSizeAdapterConfig(...); usecurrent.copyWith(...)for a replacement configuration. - Replace
scaleForViewId(viewId)andconfigForViewId(viewId)withscaleForView(view)andconfigForView(view). - Replace extension-based sizing with plain values or standard Flutter APIs:
100.dpbecomes100,14.spbecomes14, and0.5.swbecomesMediaQuery.sizeOf(context).width * 0.5. - Use
ScreenSizeAdapter.scaleOf(context)for scale reads. UseScreenSizeAdapterScopearound manually mounted non-primary views. - In
testWidgets, useScreenSizeTestEnvironmentfor MediaQuery-only checks orScreenSizeTestViewportwhen assertions also depend on adapted layout constraints; neither installs the production binding.
0.2.0 - 2026-04-15 #
Changed #
- Improved the example app with runtime design-size controls and scale-bound information.
- Raised the minimum Flutter requirement to
3.16.0fortextScalersupport.
0.1.0 - 2026-02-09 #
Added #
- Added
ScreenSizeAdapterConfigandScreenSizeTextScaleModefor.spbehavior control. - Added
ScreenSizeAdapter.setDesignSize(context, size)andScreenSizeAdapter.reset(context)for runtime relayout-safe updates. - Added
ScreenSizeHelper.initializeForTest(...)for deterministic test setup. - Added package and example smoke tests for adapter behavior.
- Added a CI workflow for static analysis and tests.
Changed #
ScreenSizeWidgetsFlutterBinding.ensureInitializedsupports optional config.- Replaced
dart:ioplatform detection with Flutter platform APIs. - Updated Chinese and English README usage and FAQ sections.
- Mobile scaling remains enabled by default; desktop scaling is disabled by default.
Fixed #
- Fixed desktop scale recalculation after metrics changes.
- Fixed test documentation that recommended an initialization path which throws at runtime.