Skip to content

Commit

Permalink
fix: bump flutter version with griddisplay
Browse files Browse the repository at this point in the history
  • Loading branch information
omariosouto committed Jan 26, 2022
1 parent fa0ed16 commit 18a117d
Showing 1 changed file with 26 additions and 9 deletions.
35 changes: 26 additions & 9 deletions lib/components/griddisplay/griddisplay.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ class GridDisplay<DataItem> extends StatelessWidget {
final List<DataItem> data;
final StyleSheet styleSheet;
final Map<Breakpoints, int> crossAxisCount;
final Map<Breakpoints, int> crossAxisSpacing;
final Map<Breakpoints, int> mainAxisSpacing;
final Widget Function(BuildContext, int, DataItem) itemBuilder;

BoxBaseStyles _boxStyles(
Expand Down Expand Up @@ -32,6 +34,12 @@ class GridDisplay<DataItem> extends StatelessWidget {
this.crossAxisCount = const {
Breakpoints.xs: 1,
},
this.crossAxisSpacing = const {
Breakpoints.xs: 1,
},
this.mainAxisSpacing = const {
Breakpoints.xs: 1,
},
this.styleSheet = const StyleSheet(),
}) : super(key: key);

Expand All @@ -42,17 +50,28 @@ class GridDisplay<DataItem> extends StatelessWidget {
activeBreakpoint: activeBreakpoint,
styleSheet: styleSheet,
);
var _crossAxisCount = resolveValueForBreakpoint(
crossAxisCount,
activeBreakpoint,
);
var _crossAxisSpacing = resolveValueForBreakpoint(
crossAxisSpacing,
activeBreakpoint,
);
var _mainAxisSpacing = resolveValueForBreakpoint(
mainAxisSpacing,
activeBreakpoint,
);

return Box(
externalStyles: _boxStyles(styleSheet, activeBreakpoint),
children: [
GridView.builder(
shrinkWrap: true,
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount:
resolveValueForBreakpoint(crossAxisCount, activeBreakpoint),
crossAxisSpacing: 5,
mainAxisSpacing: 5,
crossAxisCount: _crossAxisCount,
crossAxisSpacing: _crossAxisSpacing,
mainAxisSpacing: _mainAxisSpacing,
),
padding: EdgeInsets.only(
left: styles.paddingLeft,
Expand All @@ -61,11 +80,9 @@ class GridDisplay<DataItem> extends StatelessWidget {
bottom: styles.paddingBottom,
),
itemCount: data.length,
itemBuilder: (context, index) => itemBuilder(
context,
index,
data[index],
),
itemBuilder: (context, index) {
return itemBuilder(context, index, data[index]);
},
),
],
);
Expand Down

2 comments on commit 18a117d

@vercel
Copy link

@vercel vercel bot commented on 18a117d Jan 26, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 18a117d Jan 26, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.