build method
Widget
build(
- BuildContext context,
- AppState appState,
- PageState pageState,
- AppStylesState stylesState,
- dynamic nodeState,
override
Implementation
@override
Widget build(
BuildContext context,
AppState appState,
PageState pageState,
AppStylesState stylesState,
WidgetState nodeState,
) {
final crossAxisCountString = crossAxisCount.get(
context: context,
loop: nodeState.loop,
);
final mainAxisSpacingString = mainAxisSpacing.get(
context: context,
loop: nodeState.loop,
);
final crossAxisSpacingString = crossAxisSpacing.get(
context: context,
loop: nodeState.loop,
);
final childAspectRatioString = childAspectRatio.get(
context: context,
loop: nodeState.loop,
);
if (jsonGetAttribute.isValid) {
return GridView.builder(
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: int.tryParse(crossAxisCountString) ?? 2,
mainAxisSpacing: double.tryParse(mainAxisSpacingString) ?? 2,
crossAxisSpacing: double.tryParse(crossAxisSpacingString) ?? 2,
childAspectRatio: double.tryParse(childAspectRatioString) != null &&
(double.tryParse(childAspectRatioString) ?? 0) > 0.1
? double.parse(childAspectRatioString)
: 1,
),
padding: const EdgeInsets.all(0),
shrinkWrap: shrinkWrap,
primary: isPrimary,
scrollDirection: direction.get(context: context) ?? Axis.vertical,
itemCount: jsonGetAttribute.getCountForLists(
context,
nodeState.loop,
),
itemBuilder: (_, index) => children.isEmpty
? const SizedBox.shrink()
: ChildBuilder(
context: context,
state: nodeState.copyWith(node: children.first, loop: index),
child: children.first,
).build(),
);
}
final finalChildren = const NodeOverrideExecuter()
.executeChildren(context, nodeState, children);
if (finalChildren.isEmpty) {
return const SizedBox();
}
return GridView.builder(
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: int.tryParse(crossAxisCountString) ?? 2,
mainAxisSpacing: double.tryParse(mainAxisSpacingString) ?? 2,
crossAxisSpacing: double.tryParse(crossAxisSpacingString) ?? 2,
childAspectRatio: double.tryParse(childAspectRatioString) != null &&
(double.tryParse(childAspectRatioString) ?? 0) > 0.1
? double.parse(childAspectRatioString)
: 1,
),
padding: const EdgeInsets.all(0),
shrinkWrap: shrinkWrap,
primary: isPrimary,
scrollDirection: direction.get(context: context) ?? Axis.vertical,
itemCount: finalChildren.length,
itemBuilder: (_, index) => finalChildren[index],
);
}