appdimens_core library
Author & Developer: Jean Bodenberg GIT: https://github.com/bodenberg/appdimens
Library: AppDimens
Core barrel — pure math, enums, cache and engine (no widget imports).
Classes
- AppDimensContext
- EN: Platform-neutral window handle. Non-widget APIs take one of these; the Dart port mirrors the Kotlin contract so every calculation is testable without a widget tree.
- AppDimensContextLike
- Structural window view needed by the engine — satisfied by every AppDimensContext and by test fakes; keeps core import cycles flat.
- AppDimensScope
-
EN: Global resolution scope — the Flutter analog of the KMP
metricsScope/ ComposeLocalDimenMetrics.AppDimensProviderpublishes each window snapshot here sonum.sdp-style getters resolve through one static read + one multiply (the fast lane). - CacheKey
- Immutable cache key (web-safe: no 64-bit bit packing, exact equality).
- CacheStats
-
Immutable cache statistics (mirrors KMP
CacheStats). - DesignScaleConstants
- Author & Developer: Jean Bodenberg GIT: https://github.com/bodenberg/appdimens
- DimenCache
-
EN: Snapshot-partitioned memoization shared by code APIs, widgets and every
strategy satellite. The dominant families bypass the hash entirely on the
default path because one multiply (~2 ns native) beats a lookup — exactly
like the Kotlin engine (
shouldBypassCache). - DimenCalculationPlumbing
- EN: Inverter resolution, multi-window detection and dp reads. Each strategy module applies its own formula on top of this.
- DimenMetrics
- EN: A value snapshot, not a process-wide mutable "current screen". The constructor contains only the inputs that affect a result; derived factors are calculated once when the snapshot is created. Equality is therefore an exact cache-partition key.
- DimenScaledEngine
-
EN: Scaled engine. Mirrors the Kotlin
calculateScaledDpexactly: - FakeAppDimensContext
- Fixed context for tests, previews and headless engines.
- MetricsChangeNotifier
- Internal listenable fired by AppDimensScope on each publication.
- ResizeBound
- EN: Bound for a resize range: fixed dp, fixed sp, or a percent of an axis.
- ResizeFixedDp
- Fixed dp bound.
- ResizeFixedSp
- Fixed sp bound.
- ResizeMath
-
EN: Resize math — builds a monotonic step table (max 4096 entries, always
ends at
maxPx) and binary-searches the largest step whose predicate fits. MirrorsResizeMathin Kotlin. - ResizePercent
-
Percent-of-axis bound (
valuein 0…100). - ResizeRangePx
- Precomputed resize range with a fitting resolver.
- ScreenConfiguration
- ScreenConfigurationLike
- Screen-configuration subset needed by bounds (avoids widget imports).
- SnapshotCache
- Per-snapshot cache partition with bounded capacity.
- ViewAppDimensContext
- EN: Context built from a FlutterView (no widget tree required). Works on every Flutter platform and updates naturally because callers re-create it per resolution or via AppDimensProvider.
Enums
- AutoResizePercentBasis
- Author & Developer: Jean Bodenberg GIT: https://github.com/bodenberg/appdimens
- CalcType
- Calculation family encoded in a CacheKey.
- DimensOrientation
- Author & Developer: Jean Bodenberg GIT: https://github.com/bodenberg/appdimens
- DpQualifier
- Author & Developer: Jean Bodenberg GIT: https://github.com/bodenberg/appdimens
- DpQualifierLike
- Local axis mirror (keeps this file independent of the common enums).
- Inverter
- Author & Developer: Jean Bodenberg GIT: https://github.com/bodenberg/appdimens
- OrientationRequest
-
Builder-facing orientation request used by DimenScaled-style chains and
facilitators (
*Rotate). - UiModeType
- Author & Developer: Jean Bodenberg GIT: https://github.com/bodenberg/appdimens
- UnitType
- Author & Developer: Jean Bodenberg GIT: https://github.com/bodenberg/appdimens
- ValueType
- Output unit encoded in a CacheKey.
Extensions
- AppDimensContextX on AppDimensContext
- Shared helpers to read the effective axis of a context.
Functions
-
resizeFixedDp(
double dp) → ResizeBound - Convenience constructors mirroring the Kotlin helpers.
-
resizeFixedSp(
double sp) → ResizeBound -
resizePercentH(
double percent) → ResizeBound -
resizePercentSw(
double percent) → ResizeBound -
resizePercentW(
double percent) → ResizeBound