Skip to main content

physical_diagonal 2.1.0 copy "physical_diagonal: ^2.1.0" to clipboard
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 reading context.isTabletLayout now rebuild only when crossing tabletThreshold.
  • Add: Hardware physicalPpi and logicalPpi in PhysicalMetrics, plus real-world unit conversions (context.mm(), context.cm(), context.inches(), and PhysicalSizedBox).
  • Add: PhysicalLayoutBuilder and PhysicalLayoutBuilder.adaptive for declarative responsive layouts.
  • Add: Deterministic test overrides via PhysicalMetricsScope(overrideMetrics: ...) and PhysicalDiagonal.setMockMetrics(...) / PhysicalDiagonal.resetMockMetrics().
  • Add: PhysicalDiagonal.resetForTesting() (@visibleForTesting) resets initialization state, mock metrics and the cached screen diagonal between tests.
  • Change: PhysicalMetricsScope.tabletThreshold is now always applied to overrideMetrics; a tabletThreshold set on the PhysicalMetrics passed as overrideMetrics is overridden by the scope's value. Changing overrideMetrics re-resolves the metrics with the scope's threshold.
  • Fix: Added global iPhone19,7 identifier for iPhone 18 Pro Max (6.9") alongside US iPhone19,3.
  • Fix: iOS didChangeMetrics queries the platform channel only when the view's physical size or devicePixelRatio changes; keyboard and inset animations no longer trigger it.
  • Fix: PhysicalMetricsScope no longer subscribes to the Android EventChannel (or refreshes iOS metrics) when the native channel is unavailable, e.g. under flutter test, where defaultTargetPlatform is Android. A native answer with -1 values (no Activity yet) still counts as available.
  • Refactor: Replaced dart:io Platform checks with defaultTargetPlatform (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.platformVersion removed. Replaced by PhysicalDiagonal.ensureInitialized() (call before runApp) and the PhysicalMetricsScope widget / context.physical getter. See README for the new usage.
  • Add: windowDiagonal — physical diagonal of the current window, distinct from deviceDiagonal (the full-screen diagonal). Tracks split-screen, multi-window, folding, and Stage Manager resizing.
  • Add: isTabletLayout with a configurable tabletThreshold.
  • Fix: Android now reads computeCurrentWindowMetrics for windowDiagonal and computeMaximumWindowMetrics for deviceDiagonal separately, guards display.getRealMetrics behind an SDK check (real API 30+, minSdk 21), and implements the full ComponentCallbacks2 contract (onTrimMemory included) so window/orientation changes push live updates.
  • Fix: Android namespace/package changed from the template default com.example.physical_diagonal to dev.ivanitsky.physical_diagonal. namespace is now declared in build.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,9 previously mapped to the wrong physical size).
  • Fix: iOS window-resize ratio computed from a screenLogicalDiagonal value read from the active UIWindowScene (with a UIScreen.main fallback), 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 the UIWindowScene/connectedScenes APIs this release depends on.
  • Add: example/ app demonstrating ensureInitialized, 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%).

2
likes
160
points
628
downloads

Documentation

API reference

Publisher

verified publisherivanitsky.top

Weekly Downloads

Device and current-window physical screen diagonal (inches), real PPI, millimeter/inch unit conversion, and adaptive tablet layout detection.

Homepage
Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

flutter

More

Packages that depend on physical_diagonal

Packages that implement physical_diagonal