Skip to content

Instantly share code, notes, and snippets.

@haashem
Created September 25, 2022 17:45
Show Gist options
  • Save haashem/8ef8c9eeb0988f22dc7f117b51d3466c to your computer and use it in GitHub Desktop.
Save haashem/8ef8c9eeb0988f22dc7f117b51d3466c to your computer and use it in GitHub Desktop.
Responsive static methods
import 'package:flutter/material.dart';
// This size work fine on my design, maybe you need some customization depends on your design
const _desktopMinSize = 1100;
const _tabletMinSize = 740;
class Responsive {
// This isMobile, isTablet, isDesktop helep us later
static bool isMobile(BuildContext context) =>
MediaQuery.of(context).size.width < _tabletMinSize;
static bool isTablet(BuildContext context) =>
MediaQuery.of(context).size.width < _desktopMinSize &&
MediaQuery.of(context).size.width >= _tabletMinSize;
static bool isDesktop(BuildContext context) =>
MediaQuery.of(context).size.width >= _desktopMinSize;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment