Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Presentation] Calculate the cross axis count depending on the device…
… type and orientation
- Loading branch information
Showing
6 changed files
with
49 additions
and
7 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:responsive_builder/responsive_builder.dart'; | ||
|
||
class GridUtils { | ||
static int getCrossAxisCount(BuildContext context) { | ||
final isPortrait = MediaQuery.of(context).orientation == Orientation.portrait; | ||
final size = MediaQuery.of(context).size; | ||
final deviceType = getDeviceType(size); | ||
final refinedSize = getRefinedSize(size); | ||
int crossAxisCount = 2; | ||
switch (deviceType) { | ||
case DeviceScreenType.mobile: | ||
crossAxisCount = isPortrait ? 2 : 3; | ||
break; | ||
case DeviceScreenType.tablet: | ||
crossAxisCount = isPortrait ? 3 : 5; | ||
break; | ||
case DeviceScreenType.desktop: | ||
switch (refinedSize) { | ||
case RefinedSize.small: | ||
crossAxisCount = 2; | ||
break; | ||
case RefinedSize.normal: | ||
crossAxisCount = 3; | ||
break; | ||
case RefinedSize.large: | ||
crossAxisCount = 5; | ||
break; | ||
case RefinedSize.extraLarge: | ||
crossAxisCount = 7; | ||
break; | ||
} | ||
break; | ||
default: | ||
break; | ||
} | ||
return crossAxisCount; | ||
} | ||
} |
This file contains 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