ResponsiveMedia class

Import the Flutter material package for widgets and utilities This class is responsible for adapting UI elements to different screen sizes and orientations.

Available extensions

Constructors

ResponsiveMedia.testInstance({required double screenHeight, required double screenWidth, required Orientation orientation, required double shortestSide, required double longestSide, double scale = 1})
Public factory constructor for testing purposes
factory

Properties

body double
Responsive body text, dynamically adjusts the size
no setter
buttonText double
Responsive button text, dynamically adjusts the size
no setter
caption double
Responsive caption text, dynamically adjusts the size
no setter
currentBreakpoint String

Available on ResponsiveMedia, provided by the AdvancedBreakpoints extension

Returns the name of the current active custom breakpoint Returns the largest breakpoint name that the screen width satisfies Returns 'unknown' if no custom breakpoints are defined or matched
no setter
h1 double
Dynamically calculated typography sizes for headings and other text elements These sizes are scaled based on the 'shortestSide' and breakpoints
no setter
h2 double
responsive h2 it will dynamicly ajust the size
no setter
h3 double
responsive h3 it will dynamicly ajust the size
no setter
h4 double
responsive h4 it will dynamicly ajust the size
no setter
h5 double
responsive h5 it will dynamicly ajust the size
no setter
h6 double
responsive h6 it will dynamicly ajust the size
no setter
hashCode int
The hash code for this object.
no setterinherited
isDesktop bool

Available on ResponsiveMedia, provided by the AdvancedBreakpoints extension

Determines if the current device is a desktop Based on screen width being greater than or equal to the tablet breakpoint threshold
no setter
isLandscape bool
Determines if the screen is in landscape mode
no setter
isMobile bool

Available on ResponsiveMedia, provided by the AdvancedBreakpoints extension

Determines if the current device is a mobile device Based on screen width being less than the mobile breakpoint threshold
no setter
isPortrait bool
Determines if the screen is in portrait mode
no setter
isTablet bool

Available on ResponsiveMedia, provided by the AdvancedBreakpoints extension

Determines if the current device is a tablet Based on screen width being between mobile and tablet breakpoint thresholds
no setter
longestSide double
The largest side of the screen (height in portrait, width in landscape)
final
orientation Orientation
Stores the current orientation of the device (portrait or landscape)
final
overline double
Responsive overline text, dynamically adjusts the size
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
scale double
A scaling factor to allow global custom scaling for all sizes
final
screenHeight double
it is Main class
final
screenWidth double
screenHeight Holds the height of the screen in pixels Holds the width of the screen in pixels
final
shortestSide double
The smallest side of the screen (width in portrait, height in landscape)
final
sizeCategory String
Determines the size category based on the screen width, useful for responsive design breakpoints
no setter
spacingL double
Large spacing
no setter
spacingM double
Mediam spacing
no setter
spacingS double
Small devices get slightly more spacing
no setter
spacingXL double
extra spacing
no setter
spacingXS double
spacing to for gaps Dynamic spacing for gaps
no setter
subtitle double
Responsive subtitle, dynamically adjusts the size
no setter
title double
responsive title it will dynamicly ajust the size Responsive title, dynamically adjusts the size
no setter

Methods

between(String startBreakpoint, String endBreakpoint) bool

Available on ResponsiveMedia, provided by the AdvancedBreakpoints extension

Checks if the current screen width is between two custom breakpoints Returns true if the screen width is within the range (inclusive of start, exclusive of end) Returns false if either breakpoint name is not found in customBreakpoints
dynamicSize(Map<String, double> sizes) double
Returns a dynamic size based on the current size category sizes is a map where keys are size categories ('XS', 'S', etc.) and values are their corresponding sizes
fromHeight(double factor) double
Method to calculate height as a percentage of screen height
fromWidth(double factor) double
Method to calculate width as a percentage of screen width
gap({Widget? customWidget, double? size, bool isHorizontal = false}) Widget
Function to create a gap widget
gapL({bool isHorizontal = false, double scale = 1.0}) Widget
Large gap (spacingL)
gapM({bool isHorizontal = false, double scale = 1.0}) Widget
Medium gap (spacingM)
gapS({bool isHorizontal = false, double scale = 1.0}) Widget
Small gap (spacingS)
gapXL({bool isHorizontal = false, double scale = 1.0}) Widget
Extra-large gap (spacingXL)
gapXS({bool isHorizontal = false, double scale = 1.0}) Widget
Predefined gaps for convenience, now supporting both vertical and horizontal orientations and scaling. Default is vertical, but can be switched to horizontal using isHorizontal: true. Extra-small gap (spacingXS)
getResponsiveBox(double portraitValue, double landscapeValue) double
  • portraitValue: The value to use for portrait orientation.
  • landscapeValue: The value to use for landscape orientation.
  • isBreakpoint(String breakpointName) bool

    Available on ResponsiveMedia, provided by the AdvancedBreakpoints extension

    Checks if the current screen width matches a custom breakpoint Returns true if the screen width is greater than or equal to the specified breakpoint Returns false if the breakpoint name is not found in customBreakpoints
    largerThan(String breakpointName) bool

    Available on ResponsiveMedia, provided by the AdvancedBreakpoints extension

    Checks if the current screen width is larger than a custom breakpoint Returns true if the screen width is strictly greater than the specified breakpoint Returns false if the breakpoint name is not found in customBreakpoints
    marginAll(double value) EdgeInsets
    Responsive margin for all sides
    marginHorizontal(double value) EdgeInsets
    Responsive margin for horizontal sides (left and right)
    marginVertical(double value) EdgeInsets
    Responsive margin for vertical sides (top and bottom)
    noSuchMethod(Invocation invocation) → dynamic
    Invoked when a nonexistent method or property is accessed.
    inherited
    paddingAll(double value) EdgeInsets
    Responsive padding for all sides
    paddingHorizontal(double value) EdgeInsets
    Responsive padding for horizontal sides (left and right)
    paddingVertical(double value) EdgeInsets
    Responsive padding for vertical sides (top and bottom)
    responsiveValue(double value) double
    In landscape mode, use the screen width for scaling.
    smallerThan(String breakpointName) bool

    Available on ResponsiveMedia, provided by the AdvancedBreakpoints extension

    Checks if the current screen width is smaller than a custom breakpoint Returns true if the screen width is strictly less than the specified breakpoint Returns false if the breakpoint name is not found in customBreakpoints
    toString() String
    Provides a string representation of the instance for debugging
    override
    valueByBreakpoint<T>({required Map<String, T> breakpointValues, required T defaultValue}) → T

    Available on ResponsiveMedia, provided by the AdvancedBreakpoints extension

    Returns a value based on custom breakpoint Returns the value associated with the current active breakpoint Returns defaultValue if no matching breakpoint is found
    valueByDevice<T>({required T mobile, required T tablet, required T desktop}) → T

    Available on ResponsiveMedia, provided by the AdvancedBreakpoints extension

    Returns a value based on device type Useful for returning different values for mobile, tablet, and desktop

    Operators

    operator ==(Object other) bool
    The equality operator.
    inherited

    Static Properties

    instance ResponsiveMedia
    Getter to retrieve the singleton instance of ResponsiveMedia
    no setter

    Static Methods

    init(BuildContext context, {double? customHeight, double? customWidth, double scale = 1}) → void
    Initializes the ResponsiveMedia singleton. Must be called in the app's build method.