import 'package:flutter/material.dart';

class GridViewWidget extends StatelessWidget {
  final Widget Function(int) child;
  final int itemCount;
  final int? count;
  final double? mainAxisExtent;
  final ScrollController? scrollController;
  const GridViewWidget(
      {super.key,
      required this.child,
      this.scrollController,
      this.mainAxisExtent,
      required this.itemCount,
      this.count});

  @override
  Widget build(BuildContext context) {
    return GridView.builder(
        controller: scrollController,
        itemCount: itemCount,
        physics: const NeverScrollableScrollPhysics(),
        scrollDirection: Axis.vertical,
        padding: const EdgeInsets.symmetric(horizontal: 20),
        gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
          crossAxisCount: count ?? 3,
          mainAxisSpacing: 15,
          crossAxisSpacing: 15,
          mainAxisExtent: mainAxisExtent,
        ),
        shrinkWrap: true,
        itemBuilder: (context, index) {
          return child(index);
        });
  }
}
