Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Flutter Device Based On BoxConstraints
import 'package:flutter/material.dart';
const kTabletSize = Size(500, 700);
const kListWidthSize = 300.0;
const kTabletBreakpoint = 720.0;
const kDesktopBreakpoint = 1200.0;
enum DeviceSize { mobile, tablet, desktop }
extension LayoutUtils on BoxConstraints {
DeviceSize get device {
if (this.maxWidth >= kDesktopBreakpoint) {
return DeviceSize.desktop;
if (this.maxWidth >= kTabletBreakpoint) {
return DeviceSize.tablet;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.