physical_diagonal 2.1.0
physical_diagonal: ^2.1.0 copied to clipboard
Device and current-window physical screen diagonal (inches), real PPI, millimeter/inch unit conversion, and adaptive tablet layout detection.
2.1.0 #
- Add: Granular widget rebuilds via
InheritedModel<PhysicalAspect>(context.isTabletLayout,context.windowDiagonal,context.deviceDiagonal). Widgets readingcontext.isTabletLayoutnow rebuild only when crossingtabletThreshold. - Add: Hardware
physicalPpiandlogicalPpiinPhysicalMetrics, plus real-world unit conversions (context.mm(),context.cm(),context.inches(), andPhysicalSizedBox). - Add:
PhysicalLayoutBuilderandPhysicalLayoutBuilder.adaptivefor declarative responsive layouts. - Add: Deterministic test overrides via
PhysicalMetricsScope(overrideMetrics: ...)andPhysicalDiagonal.setMockMetrics(...)/PhysicalDiagonal.resetMockMetrics(). - Add:
PhysicalDiagonal.resetForTesting()(@visibleForTesting) resets initialization state, mock metrics and the cached screen diagonal between tests. - Change:
PhysicalMetricsScope.tabletThresholdis now always applied tooverrideMetrics; atabletThresholdset on thePhysicalMetricspassed asoverrideMetricsis overridden by the scope's value. ChangingoverrideMetricsre-resolves the metrics with the scope's threshold. - Fix: Added global
iPhone19,7identifier for iPhone 18 Pro Max (6.9") alongside USiPhone19,3. - Fix: iOS
didChangeMetricsqueries the platform channel only when the view's physical size ordevicePixelRatiochanges; keyboard and inset animations no longer trigger it. - Fix:
PhysicalMetricsScopeno longer subscribes to the AndroidEventChannel(or refreshes iOS metrics) when the native channel is unavailable, e.g. underflutter test, wheredefaultTargetPlatformis Android. A native answer with-1values (no Activity yet) still counts as available. - Refactor: Replaced
dart:ioPlatformchecks withdefaultTargetPlatform(package:flutter/foundation.dart) for seamless cross-platform testing.
2.0.3 #
- Docs: README updated — supported iOS device table (iPhone 17/18 families, iPhone Duo, latest iPads), iPhone Duo display selection, iOS Simulator behavior.
2.0.2 #
- Add: Support for the latest iPhone and iPad models (including foldable dual-display configurations).
- Fix: Improved physical diagonal detection in iOS Simulator environments.
2.0.1 #
- Maintenance and package metadata updates.
2.0.0 #
Breaking rewrite. Nothing from 0.1.1 is backward compatible.
- Breaking:
PhysicalDiagonal.platformVersionremoved. Replaced byPhysicalDiagonal.ensureInitialized()(call beforerunApp) and thePhysicalMetricsScopewidget /context.physicalgetter. See README for the new usage. - Add:
windowDiagonal— physical diagonal of the current window, distinct fromdeviceDiagonal(the full-screen diagonal). Tracks split-screen, multi-window, folding, and Stage Manager resizing. - Add:
isTabletLayoutwith a configurabletabletThreshold. - Fix: Android now reads
computeCurrentWindowMetricsforwindowDiagonalandcomputeMaximumWindowMetricsfordeviceDiagonalseparately, guardsdisplay.getRealMetricsbehind an SDK check (real API 30+,minSdk21), and implements the fullComponentCallbacks2contract (onTrimMemoryincluded) so window/orientation changes push live updates. - Fix: Android namespace/package changed from the template default
com.example.physical_diagonaltodev.ivanitsky.physical_diagonal.namespaceis now declared inbuild.gradle(required by current AGP). - Fix: iOS unrecognized machine identifiers no longer report a fixed phone
diagonal (this inverted tablet detection for any iPad released after the
table was written). Falls back to
UIDevice.userInterfaceIdiom. - Fix: iOS identifier table — four entries corrected against Apple's
published identifiers (
iPhone14,3,iPhone14,5,iPhone14,7,iPad13,8/iPad13,9previously mapped to the wrong physical size). - Fix: iOS window-resize ratio computed from a
screenLogicalDiagonalvalue read from the activeUIWindowScene(with aUIScreen.mainfallback), instead of a hardcoded points-per-inch constant. - Add: Swift Package Manager support alongside CocoaPods
(
ios/physical_diagonal/Package.swift), ahead of the CocoaPods trunk read-only cutover (2026-12-02). iOS deployment target raised to 13.0 — required by theUIWindowScene/connectedScenesAPIs this release depends on. - Add:
example/app demonstratingensureInitialized,PhysicalMetricsScope, and a live threshold slider.
0.1.1 #
Adding proper documentation.
0.0.1 #
Physical diagonal of the screen helps to optimize design for Tablets/bigger screens. Calculation relies on system pixel density information, so it might be slightly inaccurate for Android devices (about 5%).