Breakpoint class

A class to define the conditions that distinguish between types of screens.

Adaptive apps usually display differently depending on the screen type: a compact layout for smaller screens, or a relaxed layout for larger screens. Override this class by defining isActive to fetch the screen property (usually MediaQuery.of) and return true if the condition is met.

Breakpoints do not need to be exclusive because they are tested in order with the last Breakpoint active taking priority.

If the condition is only based on the screen width and/or the device type, use WidthPlatformBreakpoint to define the Breakpoint.

See also:

Constructors

Breakpoint.new({double? beginWidth, double? endWidth, double? beginHeight, double? endHeight, bool andUp = false, Set<TargetPlatform>? platform, double spacing = kMaterialMediumAndUpSpacing, double margin = kMaterialMediumAndUpMargin, double padding = kMaterialPadding, int recommendedPanes = 1, int maxPanes = 1})
Returns a const Breakpoint with the given constraints.
const
Breakpoint.extraLarge({bool andUp = false, Set<TargetPlatform>? platform})
Returns a Breakpoint with the given constraints for an extraLarge screen.
const
Breakpoint.large({bool andUp = false, Set<TargetPlatform>? platform})
Returns a Breakpoint with the given constraints for a large screen.
const
Breakpoint.medium({bool andUp = false, Set<TargetPlatform>? platform})
Returns a Breakpoint with the given constraints for a medium screen.
const
Breakpoint.mediumLarge({bool andUp = false, Set<TargetPlatform>? platform})
Returns a Breakpoint with the given constraints for a mediumLarge screen.
const
Breakpoint.small({bool andUp = false, Set<TargetPlatform>? platform})
Returns a Breakpoint with the given constraints for a small screen.
const
Breakpoint.standard({Set<TargetPlatform>? platform})
Returns a Breakpoint that can be used as a fallthrough in the case that no other breakpoint is active.
const

Properties

andUp bool
When set to true, it will include any size above the set width and set height.
final
beginHeight double?
The beginning height dp value. If left null then the Breakpoint will have no lower bound.
final
beginWidth double?
The beginning width dp value. If left null then the Breakpoint will have no lower bound.
final
endHeight double?
The end height dp value. If left null then the Breakpoint will have no upper bound.
final
endWidth double?
The end width dp value. If left null then the Breakpoint will have no upper bound.
final
hashCode int
The hash code for this object.
no setterinherited
margin double
The default material margin for the Breakpoint.
final
maxPanes int
The material maximum number of panes that can be displayed on the Breakpoint.
final
padding double
The default material padding for the Breakpoint.
final
platform Set<TargetPlatform>?
A Set of TargetPlatforms that the Breakpoint will be active on. If left null then it will be active on all platforms.
final
recommendedPanes int
The material recommended number of panes for the Breakpoint.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
spacing double
The default material spacing for the Breakpoint.
final

Methods

between(Breakpoint lower, Breakpoint upper) bool
Returns true if this Breakpoint is between the given Breakpoints.
isActive(BuildContext context) bool
A method that returns true based on conditions related to the context of the screen such as MediaQuery.sizeOf(context).width, MediaQuery.sizeOf(context).height and MediaQuery.orientationOf(context).
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator <(Breakpoint breakpoint) bool
Returns true if this Breakpoint is less than the given Breakpoint.
operator <=(Breakpoint breakpoint) bool
Returns true if this Breakpoint is less than or equal to the given Breakpoint.
operator ==(Object other) bool
The equality operator.
inherited
operator >(Breakpoint breakpoint) bool
Returns true if this Breakpoint is greater than the given Breakpoint.
operator >=(Breakpoint breakpoint) bool
Returns true if this Breakpoint is greater than or equal to the given Breakpoint.

Static Methods

activeBreakpointIn(BuildContext context, List<Breakpoint> breakpoints) Breakpoint?
Returns the currently active Breakpoint based on the BuildContext and a list of Breakpoints.
activeBreakpointOf(BuildContext context) Breakpoint
Returns the currently active Breakpoint.
defaultBreakpointOf(BuildContext context) Breakpoint
Returns the default Breakpoint based on the BuildContext.
isDesktop(BuildContext context) bool
Returns true if the current platform is Desktop.
isMobile(BuildContext context) bool
Returns true if the current platform is Mobile.
maybeActiveBreakpointFromSlotLayout(BuildContext context) Breakpoint?
Returns the currently active Breakpoint based on the SlotLayout in the context.

Constants

desktop → const Set<TargetPlatform>
A set of TargetPlatforms that the Breakpoint will be active on desktop.
mobile → const Set<TargetPlatform>
A set of TargetPlatforms that the Breakpoint will be active on mobile.