0% found this document useful (0 votes)
16 views3 pages

Flutter Responsive Design Helper

The document defines a Flutter utility class, HelperResponsive, that provides methods for determining the screen size and responsive design breakpoints. It includes enums for various breakpoints (xs, sm, md, lg, xl) and methods to check if the current screen width falls within specific ranges, as well as methods for calculating the number of columns based on item width. Additionally, it offers methods to retrieve text styles based on the screen size, enhancing the adaptability of UI elements in a Flutter application.

Uploaded by

datornica
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views3 pages

Flutter Responsive Design Helper

The document defines a Flutter utility class, HelperResponsive, that provides methods for determining the screen size and responsive design breakpoints. It includes enums for various breakpoints (xs, sm, md, lg, xl) and methods to check if the current screen width falls within specific ranges, as well as methods for calculating the number of columns based on item width. Additionally, it offers methods to retrieve text styles based on the screen size, enhancing the adaptability of UI elements in a Flutter application.

Uploaded by

datornica
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

```

import 'package:flutter/[Link]';

enum ResponsiveBreakpoints {
xs(0),
sm(667),
md(834),
lg(1024),
xl(1400);

const ResponsiveBreakpoints([Link]);
final double value;
}

class HelperResponsive {
static bool isWithin(BuildContext context, ResponsiveBreakpoints from,
ResponsiveBreakpoints to) {
return [Link](context).[Link] >= [Link] + 1 &&
[Link](context).[Link] <= [Link] - 1;
}

static bool isXS(BuildContext context) {


return [Link](context).[Link] < [Link];
}

static bool isXSPlus(BuildContext context) {


return [Link](context).[Link] < [Link] + 1;
}

static bool isSM(BuildContext context) {


return [Link](context).[Link] >= [Link] &&
[Link](context).[Link] < [Link];
}

static bool isSMPlus(BuildContext context) {


return [Link](context).[Link] >= [Link] + 1;
}

static bool isLessThanSM(BuildContext context) {


return [Link](context).[Link] <= [Link];
}

static bool isMD(BuildContext context) {


return [Link](context).[Link] >= [Link] &&
[Link](context).[Link] <= [Link];
}

static bool isMDPlus(BuildContext context, {double leeway = 0}) {


return [Link](context).[Link] + leeway >=
[Link] + 1;
}

static bool isLessThanMD(BuildContext context) {


return [Link](context).[Link] <= [Link];
}

static bool isLG(BuildContext context) {


return [Link](context).[Link] >= [Link] &&
[Link](context).[Link] <= [Link];
}

static bool isLGPlus(BuildContext context) {


return [Link](context).[Link] >= [Link] + 1;
}

static bool isLessThanLG(BuildContext context) {


return [Link](context).[Link] <= [Link];
}

static bool isXL(BuildContext context) {


return [Link](context).[Link] >= [Link];
}

static int numberOfColumns(BuildContext context, itemWidth) {


final int size = [Link](context).[Link] ~/ itemWidth;
if (size < 1) return 1;
return size;
}

//height

static bool isMobileLandscapeHeightHeader(BuildContext context) =>


[Link](context).[Link] < [Link];
static bool isMobileLandscapeHeightMenu(BuildContext context) =>
[Link](context).[Link] < [Link] + 100;

static TextStyle getTitleStyle(BuildContext context) {


if ([Link](context, [Link],
[Link])) {
return [Link](context).[Link]!.copyWith(
fontWeight: [Link],
fontFamily: 'Poppins',
);
}
if ([Link](context)) {
return [Link](context).[Link]!.copyWith(
fontWeight: [Link],
fontFamily: 'Poppins',
);
}
return [Link](context).[Link]!.copyWith(
fontWeight: [Link],
fontFamily: 'Poppins',
);
}

static double getTitleStyleShimmer(BuildContext context) {


if ([Link](context, [Link],
[Link])) {
return 40;
}
if ([Link](context)) {
return 44;
}
return 32;
}

static TextStyle getTextStyle(BuildContext context) {


if ([Link](context)) {
return [Link](context).[Link]!.copyWith();
}
return [Link](context).[Link]!;
}
}

```

You might also like