Created
September 25, 2022 17:45
-
-
Save haashem/8ef8c9eeb0988f22dc7f117b51d3466c to your computer and use it in GitHub Desktop.
Responsive static methods
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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