globals library
Opt-in entrypoint for px_responsive's top-level global getters and
functions (isMobile, screenWidth, orientation, platformType, ...),
without the deprecation hints that importing them via
package:px_responsive/px_responsive.dart now carries.
Import this instead of (not in addition to — the two entrypoints declare the same names and cannot both be imported unprefixed) the main barrel if you specifically want these names and don't want deprecation noise:
import 'package:px_responsive/globals.dart';
import 'package:px_responsive/px_responsive.dart' hide isMobile, isTablet,
isDesktop, deviceType, screenWidth, screenHeight, effectiveWidth,
isLandscape, isPortrait, orientation, responsiveValue, orientationValue,
platformType, isNativeMobile, isNativeDesktop, isPlatformWeb;
New code should generally prefer context.responsive (scope-aware,
rebuilds correctly via PxResponsiveScope) or PxResponsive() (the
static path) over either of these global-getter entrypoints.
Properties
- deviceType → PxDeviceType
-
Returns the current device type as PxDeviceType enum.
no setter
- effectiveWidth → double
-
Returns the effective width used for scaling calculations.
no setter
- isDesktop → bool
-
Returns
trueif the current screen width is in the desktop range.no setter - isLandscape → bool
-
Returns
trueif the screen is in landscape orientation.no setter - isMobile → bool
-
Returns
trueif the current screen width is in the mobile range.no setter - isNativeDesktop → bool
-
Returns
trueif the app is running on a native desktop platform (macOS, Windows, or Linux).no setter - isNativeMobile → bool
-
Returns
trueif the app is running on a native mobile platform (Android or iOS).no setter - isPlatformWeb → bool
-
Returns
trueif the app is running in a web browser.no setter - isPortrait → bool
-
Returns
trueif the screen is in portrait orientation.no setter - isTablet → bool
-
Returns
trueif the current screen width is in the tablet range.no setter - orientation → PxOrientation
-
Returns the current screen orientation as a PxOrientation enum.
no setter
- platformType → PxPlatformType
-
Returns the current PxPlatformType based on kIsWeb and
defaultTargetPlatform.
no setter
- screenHeight → double
-
Returns the current screen height in logical pixels.
no setter
- screenWidth → double
-
Returns the current screen width in logical pixels.
no setter
Functions
-
orientationValue<
T> ({required T portrait, required T landscape}) → T - Returns the appropriate value based on the current screen orientation.
-
responsiveValue<
T> ({required T mobile, T? tablet, T? desktop}) → T - Returns the appropriate value based on current device type.