Breakpoint class

Represents an inclusive size range used for responsive styling.

Use matchesContext to evaluate the viewport size from MediaQuery, or matches to evaluate any Size, including one derived from local layout constraints.

Example usage:

const Breakpoint mobile = .maxWidth(767);
const Breakpoint tablet = .widthRange(768, 1023);
const Breakpoint desktop = .minWidth(1024);
Annotations

Constructors

Breakpoint({double? minWidth, double? maxWidth, double? minHeight, double? maxHeight})
Creates a new breakpoint with the specified constraints.
const
Breakpoint.heightRange(double minHeight, double maxHeight)
Creates a breakpoint that matches heights from minHeight to maxHeight.
const
Breakpoint.maxHeight(double maxHeight)
Creates a breakpoint that matches heights less than or equal to maxHeight.
const
Breakpoint.maxWidth(double maxWidth)
Creates a breakpoint that matches widths less than or equal to maxWidth.
const
Breakpoint.minHeight(double minHeight)
Creates a breakpoint that matches heights greater than or equal to minHeight.
const
Breakpoint.minWidth(double minWidth)
Creates a breakpoint that matches widths greater than or equal to minWidth.
const
Breakpoint.widthRange(double minWidth, double maxWidth)
Creates a breakpoint that matches widths from minWidth to maxWidth.
const

Properties

hashCode int
The hash code for this object.
no setteroverride
maxHeight double?
The maximum height for this breakpoint (inclusive). If null, there is no maximum height constraint.
final
maxWidth double?
The maximum width for this breakpoint (inclusive). If null, there is no maximum width constraint.
final
minHeight double?
The minimum height for this breakpoint (inclusive). If null, there is no minimum height constraint.
final
minWidth double?
The minimum width for this breakpoint (inclusive). If null, there is no minimum width constraint.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

matches(Size size) bool
Checks if the given size matches this breakpoint's constraints.
matchesContext(BuildContext context) bool
Checks whether this breakpoint matches the viewport size from context.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
Returns a string representation of this breakpoint for debugging.
override

Operators

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

Constants

desktop → const Breakpoint
mobile → const Breakpoint
tablet → const Breakpoint