A base class to define Flutter breakpoint properties.

Basic usage

Use default breakpoints:

Width(Logical pixels)SizeColumnsGutter
0 - 599xsmall416
600 - 719small816
720 - 839small824
840 - 1023small1224
1024 - 1439medium1224
1440 - 1919large1224
1920+xlarge1224
final media = MediaQuery.of(context);

final breakpoint = BreakpointBase(
  orientation: media.orientation,
  width: media.size.width,
);

Advanced usage

To customise breakpoints:

WidthSizeGutterExpanded(portrait)Expanded(landscape)
0 - 799small16falsetrue
800 - 1599medium24falsetrue
1600+large50truetrue
final media = MediaQuery.of(context);

final breakpoint = Breakpoint(
  orientation: media.orientation,
  width: media.size.width,
);

//
class Breakpoint extends BreakpointBase {
  Breakpoint({required Orientation orientation, required double width})
      : super(orientation: orientation, width: width);

  @override
  LayoutSize get size => _findValue({
      0: LayoutSize.small,
      800: LayoutSize.medium,
      1600: LayoutSize.large,
    });

  @override
  int get gutter => _findValue({0: 16, 800: 24, 1600: 50});

  // Add one more property
  bool get expanded => orientation == Orientation.landscape || width >= 1600;
}

Libraries

breakpoint_base