Another breakpoint framework. Aims to simplify as much as possible building adaptive layouts.

Overview

Another breakpoint framework. Aims to simplify as much as possible building adaptive layouts.

Features

  • Really simple implementation
  • Works with and without configuration
  • Customizable
  • Bootstrap breakpoints or Material Design breakpoints ready

Breakpoints

Default breakpoints (Bootstrap)

Size Name Minimum Width
X-Small xs/none 0
Small sm ≥576
Medium md ≥768
Large lg ≥992
Extra large xl ≥1200
Extra extra large xxl ≥1400

Material Design breakpoints

Size Name Minimum Width
X-Small xs/none 0
Small sm ≥600
Medium md ≥905
Large lg ≥1240
Extra large xl ≥1440
Extra extra large xxl -

Getting started

  • Import the library
import 'package:screen_breakpoints/screen_breakpoints.dart';
  • If you want to personalize all the breakpoints, wrap up any widget above MaterialApp (or any other App that you use). For example:
/* ... */
// This is just like the default configuration
const myBreakpoints = BreakpointConfiguration(
  xs: const Breakpoint(breakpoint: 0, width: double.infinity, margin: null, padding: 16, columns: 4),
  sm: const Breakpoint(breakpoint: 576, width: 540, margin: null, padding: 16, columns: 8),
  md: const Breakpoint(breakpoint: 768, width: 720, margin: null, padding: 16, columns: 12),
  lg: const Breakpoint(breakpoint: 992, width: 960, margin: null, padding: 16, columns: 12),
  xl: const Breakpoint(breakpoint: 1200, width: 1140, margin: null, padding: 24, columns: 12),
  xxl: const Breakpoint(breakpoint: 1400, width: 1320, margin: null, padding: 24, columns: 12),
);

Widget build(BuildContext context) {
  return BreakpointConfigurator(
    configuration: myBreakpoints,
    child: MaterialApp(
      /* ... */
    ),
  );
}
/* ... */

Every breakpoint is a Breakpoint type, each one has to be higher, if any set to NULL, they will default to the lower one. The default Breakpoints are based on Bootstrap To use Material change the configuration parameter to kMaterialBreakpoints:

/* ... */
Widget build(BuildContext context) {
  return BreakpointConfigurator(
    configuration: kMaterialBreakpoints,
    child: MaterialApp(
      /* ... */
    ),
  );
}
/* ... */
  • Otherwise, you can just use it, it will use the default settings.

Usage

This package contains 2 basic Widgets that you can use:

BreakpointContainer

Use it if you want to place object inside a container that will be resized based on the breakpoint. Generally good to use inside Scaffold's body. It can automatically swap children that match the layout for the current breakpoint.

/* ... */

Scaffold(
    appBar: AppBar(
        title: const BreakpointContainer(
            fluid: true,
            alignment: Alignment.center,
            xlChild: Text('Sample Items - Desktop'),
            mdChild: Text('Sample Items - Tablet'),
            child: Text('Sample Items - Mobile'),
        ),
    ),
    body: BreakpointContainer(
        decoration: BoxDecoration(color: theme.cardColor),
        xlChild: _DesktopView(),
        mdChild: _TabletView(),
        child: _MobileView(),
    ),
);

/* ... */

Parameters list:

BreakpointContainer(
    height: // Height of the container
    decoration: // Decoration of the centered Container
    backgroundDecoration: // Decoration of the Container behind
    foregroundDecoration: // Foreground decoration on top of the centered Container
    alignment: // Alignment of the centered Container
    clipBehavior: // Clipping of the centered Container
    fluid: // Setting fluid to true will ignore breakpoint's width and margin
    xxlChild: // Child to be shown at XXL Breakpoint, if null will use one below
    xlChild: // Child to be shown at XL Breakpoint, if null will use one below
    lgChild: // Child to be shown at LG Breakpoint, if null will use one below
    mdChild: // Child to be shown at MD Breakpoint, if null will use one below
    smChild: // Child to be shown at SM Breakpoint, if null will use one below
    child: // Child to be shown at XS and up Breakpoint, this one is required.
);

BreakpointBuilder

This is the builder based on the BreakpointContainer. If you need to build a complex layout for each breakpoint you can use this one. It uses the BreakpointContainer under the hood but gives back a builder that on each rebuild will provide: BuildContext, Breakpoint you are currently in and BreakpointConfiguration.

Example:

/* ... */

Scaffold(
    /* ... */
    body: BreakpointBuilder(
        decoration: BoxDecoration(color: theme.cardColor),
        builder: (context, breakpoint, configuration) {
          if(breakpoint >= configuration.xl) return _DesktopView();
          if(breakpoint >= configuration.md) return _TabletView();
          return _MobileView();
        }
    ),
    /* ... */
);

/* ... */

The outcome if the above example will be the exact same as the previous BreakpointContainer, the difference here is that you have a builder with a context in it so you can control more the result.

Parameters list:

BreakpointContainer(
    builder: // Builder that will build the widget
    height: // Height of the container
    decoration: // Decoration of the centered Container
    backgroundDecoration: // Decoration of the Container behind
    foregroundDecoration: // Foreground decoration on top of the centered Container
    alignment: // Alignment of the centered Container
    clipBehavior: // Clipping of the centered Container
    fluid: // Setting fluid to true will ignore breakpoint's width and margin
);

Find current Breakpoint

There is a simple way to find the current Breakpoint either from Context or MediaQuery. Just type inside the build function:

Widget build(BuildContext context) {
  // From Build Context
  final breakpoint = Breakpoint.fromContext(context);
  // Alternative way
  final breakpoint = context.breakpoint;
  
  // From Media Query
  final mediaQuery = MediaQuery.of(context);
  final breakpoint = Breakpoint.fromMediaQuery(mediaQuery);
}
You might also like...

AdventOfCode 2022 in Dart focusing on code golf, making the solutions as small as possible

Advent of Code 2022 in Dart (Code Golf) This is my attempt at solving the Advent of Code 2022 puzzles in the shortest possible code using Dart 2.18. Y

Dec 15, 2022

Flutter package to simplify pagination of list of items from the internet.

Flutter package to simplify pagination of list of items from the internet.

PaginationView Installing In your pubspec.yaml dependencies: pagination_view: ^2.0.0-nullsafety.0 import 'package:pagination_view/pagination_view.da

Dec 29, 2022

A flutter package to simplify pagination with firestore data 🗃

A flutter package to simplify pagination with firestore data 🗃

Pagination in Firestore Setup Use the same setup used for cloud_firestore package (or follow this). Usage In your pubspec.yaml dependencies: paginat

Dec 23, 2022

Flutter package to simplify pagination of list of items from the internet.

Flutter package to simplify pagination of list of items from the internet.

PaginationView Installing In your pubspec.yaml dependencies: pagination_view: ^2.0.0-nullsafety.0 import 'package:pagination_view/pagination_view.da

Dec 29, 2022

This a library to simplify isolate thread communication.

This a library to simplify islate thread communication. It abstracts the data transfer between islate and the main thread into a simple channel, and t

Oct 31, 2022

Additional alignments to help make your layouts more readable (TopLeft, TopRight, etc)

extra alignments Why should Center get all the love? This package adds additional alignments to help make your layouts more readable. The full set inc

Jan 6, 2023

Super Useful Flutter Layouts - Right in Your Pocket. 😉

Super Useful Flutter Layouts - Right in Your Pocket. 😉

Super Useful Flutter Layouts - Right in Your Pocket. 😉 Update: Flutter web app preview here: https://flutter-layouts-demo.web.app/ YouTube video walk

Jan 8, 2023

Package to select layout per orientation or device size like mobile vs tablet layouts or portrait vs landscape

proxy_layout Package to select layout per orientation or device size like mobile vs tablet layouts or portrait vs landscape Usage You have two widgets

Apr 18, 2021

Collection of cool Layouts built with Flutter to Inspire Other UI developers and explore the possibilities of Flutter.

Collection of cool Layouts built with Flutter to Inspire Other UI developers and explore the possibilities of Flutter.

Awesome_Flutter_Layouts Would you like to Contribute your Designs? Please refer the Contribution guidelines before you dive In Need help? or Looks Som

Nov 22, 2022
Owner
null
Helper for building advanced multi child layouts.

About Boxy is designed to overcome the limitations of Flutter's built-in layout widgets, it provides utilities for flex, custom multi-child layouts, d

Andre 329 Dec 12, 2022
The ROHD Verification Framework is a hardware verification framework built upon ROHD for building testbenches.

ROHD Verification Framework The ROHD Verification Framework (ROHD-VF) is a verification framework built upon the Rapid Open Hardware Development (ROHD

Intel Corporation 18 Dec 20, 2022
Flying Fish is full-stack Dart framework - a semi-opinionated framework for building applications exclusively using Dart and Flutter

Flying Fish is full-stack Dart framework - a semi-opinionated framework for building applications exclusively using Dart and Flutter.

Flutter Fish 3 Dec 27, 2022
A platform-adaptive search for Flutter

Flutter Platform Search Flutter platform search is an abstract implementation of the Flutter search delegate. It is a time saving way to implement a p

QuickBird Studios 32 Dec 31, 2022
In this app, it's possible to find some different kind of flutter animations

flutter_animations Apprendre à utiliser les animations avec Flutter Getting Started This project is a starting point for a Flutter application. A few

MOISE Rajesearison 0 Dec 24, 2021
Adaptive dialog - Show alert dialog or modal action sheet adaptively according to platform.

adaptive_dialog Show alert dialog or modal action sheet adaptively according to platform. showOkAlertDialog Convenient wrapper of showAlertDialog. iOS

Masayuki Ono (mono) 244 Dec 17, 2022
An Adaptive Navigation Bar in flutter. Navbar changes according to the screen size.

Adaptive NavBar (adaptive_navbar) Table of contents General info Setup Conclusion Useful Resources Meet the developer General info adaptive_navbar is

Mouli Bheemaneti 3 Oct 17, 2022
Pokedex-Flutter - Pokedex demonstrates modern Flutter development with GetX, Hive, Flow, Adaptive/Responsive Design

Pokedex-Flutter Pokedex demonstrates modern Flutter development with GetX, Hive,

Khoujani 3 Aug 17, 2022
Makes it possible to safely execute and retry a Future inside a StatelessWidget

futuristic Makes it possible to safely execute and retry a Future inside a StatelessWidget. See the Mainstream package for a similar API for working w

Martin Rybak 28 Sep 15, 2022
Klutter plugin makes it possible to write a Flutter plugin for both Android and iOS using Kotlin only.

The Klutter Framework makes it possible to write a Flutter plugin for both Android and iOS using Kotlin Multiplatform. Instead of writing platform spe

Gillian 33 Dec 18, 2022