ResponsiveConstraintsExtensions extension

Extensions on BoxConstraints for Tailwind-style responsive checks.

Provides boolean getters for each breakpoint (sm, md, lg, xl, xxl) to make responsive layouts easier inside LayoutBuilder or similar widgets.

Example usage:

LayoutBuilder(
  builder: (context, constraints) {
    if (constraints.sm) {
      print("Small screen or larger");
    }

    if (constraints.lg) {
      print("Large screen or larger");
    }

    // Conditional widget example
    return Container(
      width: constraints.md ? 500 : 300,
      child: Text(
        constraints.xl ? "Extra Large Screen" : "Smaller Screen",
      ),
    );
  },
);
on

Properties

lg bool

Available on BoxConstraints, provided by the ResponsiveConstraintsExtensions extension

Returns true if maxWidth ≥ large breakpoint
no setter
md bool

Available on BoxConstraints, provided by the ResponsiveConstraintsExtensions extension

Returns true if maxWidth ≥ medium breakpoint
no setter
sm bool

Available on BoxConstraints, provided by the ResponsiveConstraintsExtensions extension

Returns true if maxWidth ≥ small breakpoint
no setter
xl bool

Available on BoxConstraints, provided by the ResponsiveConstraintsExtensions extension

Returns true if maxWidth ≥ extra large breakpoint
no setter
xxl bool

Available on BoxConstraints, provided by the ResponsiveConstraintsExtensions extension

Returns true if maxWidth ≥ XXL breakpoint
no setter