AppDimens Flutter
August 22, 2026 · View on GitHub
Responsive dimensions for Android · iOS · Web · Windows · macOS · Linux — modular strategy library with fast-lane resolution
Write values like 16.sdp and the library scales them from the live window snapshot (size, density, font scale) — on every platform Flutter runs on, with the same math, the same API grammar and the same performance architecture as AppDimens Dynamic and AppDimens KMP.
This is a faithful Flutter port of the AppDimens family: same formulas (bit-parity constants), same suffix grammar (
sdp,sdpa,sdpPh…), same facilitators, builders, inverters, cache design and fast lane.
✨ Highlights (3.2.0)
| 🧮 14 scaling modes | Scaled (default), Percent, Power, Fluid, Auto, Logarithmic, Interpolated, Diagonal, Perimeter, Fill, Fit, Density + Resize fitting + physical units |
| ⚡ Fast lane | 16.sdp = one static snapshot read + one multiply (~6.6–8.7 ns on a modern JIT — every audited stem sits on the harness noise floor; the Kotlin engine measures 6–30 ns on device) |
| 🪟 Per-window snapshots | Immutable DimenMetrics published by AppDimensProvider; rotation, split-screen and font-scale changes self-heal — no stale values |
| 🧊 Snapshot-partitioned cache | Max 4 partitions × 512 entries; dominant families bypass the hash entirely (one multiply beats a lookup) |
| 🔤 One grammar everywhere | Suffixes a · i · ia, inverters Ph/Lh/Pw/Lw, facilitators Rotate/Mode/Qualifier/Screen (+ logic-only Plain) on every strategy |
| 🧩 Modular | Principal artifact appdimens_flutter plus one opt-in package per strategy (appdimens_percent, appdimens_power, …) and an all-in-one appdimens_bom |
| ♾️ Multiplatform | Android · iOS · Web · Windows · macOS · Linux — pure Dart engine, zero platform channels |
🚀 Quick start
Installation
All 15 packages are published on pub.dev. Add the principal artifact with:
flutter pub add appdimens_flutter # Flutter apps
dart pub add appdimens_flutter # pure-Dart packages
Optional strategy satellites — install only what you use:
flutter pub add appdimens_percent # literal % of screen axes (spaceW/spaceH)
flutter pub add appdimens_power # sub-linear growth for large screens
flutter pub add appdimens_fluid # clamped band ±20%
flutter pub add appdimens_auto # phone/tablet knee at 480 dp
flutter pub add appdimens_logarithmic # strong ±0.4·ln damping
flutter pub add appdimens_interpolated # fixed 50% blend
flutter pub add appdimens_diagonal # orientation-stable diagonal ratio
flutter pub add appdimens_perimeter # half-perimeter ratio
flutter pub add appdimens_density # dpi/160 physical alignment
flutter pub add appdimens_fill # cover-like growth
flutter pub add appdimens_fit # contain-like growth
flutter pub add appdimens_resize # constraint auto-fit widgets
flutter pub add appdimens_units # mm/cm/inch helpers
# or everything at once:
flutter pub add appdimens_bom
Equivalent pubspec.yaml:
dependencies:
appdimens_flutter: ^3.2.0 # principal artifact (core + scaled)
# optional strategies, exactly like the Kotlin satellite modules:
appdimens_percent: ^3.2.0
appdimens_auto: ^3.2.0
# …or everything at once:
appdimens_bom: ^3.2.0
Packages on pub.dev
| Package | Purpose |
|---|---|
| appdimens_flutter | Principal artifact: core engine, cache, Scaled (sdp/hdp/wdp/ssp) |
| appdimens_bom | All-in-one meta-package (whole family, one version) |
| appdimens_percent · appdimens_power · appdimens_fluid · appdimens_auto | Percent · Power · Fluid · Auto |
| appdimens_logarithmic · appdimens_interpolated · appdimens_diagonal · appdimens_perimeter | Logarithmic · Interpolated · Diagonal · Perimeter |
| appdimens_density · appdimens_fill · appdimens_fit | Density · Fill · Fit |
| appdimens_resize · appdimens_units | Constraint auto-fit · mm/cm/inch units |
The principal artifact is
appdimens_flutter— the bare nameappdimenswas blocked by the pub.dev naming-similarity policy (app_dimen).
Wrap your app once
import 'package:appdimens_flutter/appdimens.dart';
void main() => runApp(
AppDimensApp( // publishes the window snapshot
child: MaterialApp(home: const MyPage()),
),
);
Use it
import 'package:appdimens_flutter/appdimens.dart';
Box(
width: 100.wdp,
height: 48.hdp,
).padding(EdgeInsets.all(16.sdp))
.child(Text('Hello', fontSize: 16.ssp));
That exact code scales correctly on phones, tablets, foldables, desktop windows and the browser.
| Extension | Based on | Typical use |
|---|---|---|
sdp | Smallest window width | Padding, margins |
hdp | Window height | Row height |
wdp | Window width | Column width |
ssp | Same idea as sdp, for text | fontSize |
sem | Same, ignoring the system font scale | fontSize |
Suffixes
| Suffix | Meaning |
|---|---|
| (none) | Default curve |
a | Aspect-ratio aware curve |
i | Ignore multi-window heuristic (returns the raw base inside split-screen) |
ia | Both |
16.sdpa // + aspect ratio
32.hdpi // height axis + ignore multi-window
16.sspa // scalable sp + aspect ratio
Orientation inverters
32.sdpPh // SW-based; in portrait uses height
32.sdpLw // SW-based; in landscape uses width
50.hdpLw // Height-based; in landscape uses width
50.wdpLh // Width-based; in landscape uses height
Facilitators
80.sdpRotate(50) // landscape → 50 scaled instead
30.sdpMode(200, UiModeType.television) // TV → 200 scaled
60.sdpQualifier(120, DpQualifier.smallWidth, 600) // sw ≥ 600 → 120 scaled
16.sdpRotatePlain(24) // logic-only pick (no double scaling)
Builder chain
final pad = 100.scaledDp
.screen(UiModeType.television, DpQualifier.smallWidth, 600, 250)
.screenMode(UiModeType.television, 500)
.screenQualifier(DpQualifier.smallWidth, 600, 150)
.screenOrientation(OrientationRequest.landscape, 120);
// resolved.sdp → scaled value under the current window
Auto-resize widgets
AutoResizeText('Headline that must fit', minSp: 10, maxSp: 28),
AutoResizeSquare(min: 40, max: 120, child: Icon(Icons.aspect_ratio)),
Explicit context (no provider needed)
final pad = 16.sdpOf(context); // any AppDimensContext
final px = AppDimens.getDimensionInPx(context, DpQualifier.smallWidth, 16);
📦 Modules
| Package | Contents |
|---|---|
appdimens_flutter | common, core (engine/cache/metrics), scaled families, provider |
appdimens_percent … appdimens_units | One package per strategy — mirrors appdimens-kmp-* / appdimens-dynamic-* |
appdimens_bom | Meta-package re-exporting everything at a coherent version |
apps/sample | Converted sample app (strategy routing demo + benchmark dashboard) |
apps/benchlab | BenchLab competitor benchmark (A/B methodology, parity tables, reports) |
Full graph and dependency rules: DOCUMENTATION/MODULES.md.
📚 Documentation
| Resource | Use for |
|---|---|
| DOCUMENTATION/README.md | Per-strategy explanations (14 guides) |
| DOCUMENTATION/API-CONVENTIONS.md | Every extension property & facilitator catalog |
| DOCUMENTATION/MATHEMATICS-AND-CALCULUS.md | Formal math, constants, precision policy |
| DOCUMENTATION/MODULES.md | Package graph |
| GUIDE-FOR-BEGINNERS.md | Plain-language walkthrough |
| PERFORMANCE.md / PERFORMANCE-COMPARATIVE.md | Measured numbers and competitor comparison |
| MIGRATION.md | Replacing the deprecated 2.x Flutter API |
| LLMS.txt · skills/ | AI-agent resources (LLM index + agent workflow skill) |
Recommendation order for most apps: Scaled (with or without a) → then percent → then auto; explore the rest when you have a clear need (fluid, fit, diagonal…).
🖥️ Example apps
apps/sample— every section of the demo (core extensions, inverters, facilitators, builder chains, auto-resize) plus a benchmark dashboard.apps/benchlab— the BenchLab pipeline (UI probe, isolate engine probe, legacy T1/T2/T3 passes, resolution-parity tables, report export).
flutter run --device <id> -t lib/main.dart # inside apps/sample or apps/benchlab
🤝 Contributing & community
- CONTRIBUTING.md · CODE_OF_CONDUCT.md · SECURITY.md
- Strategy packages are generated from
scripts/generate_satellites.py(single source of truth for the shared grammar). - ⭐ Star the repository to follow updates!
Apache License 2.0 — responsive layout utilities for Flutter (Android · iOS · Web · Windows · macOS · Linux). Part of the AppDimens family: Android/Dynamic · KMP · Flutter.