Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
42 kB
2
Indexable
Never
// ignore_for_file: prefer_const_constructors, prefer_const_literals_to_create_immutables

import 'package:druto_shopping/apps/exclusiveOffersPage/exclusive_offers_page_view.dart';
import 'package:druto_shopping/apps/homepage/models/models.dart';
import 'package:druto_shopping/apps/homepage/models/products_model.dart';
import 'package:druto_shopping/apps/homepage/repository/homepage_repo.dart';
import 'package:druto_shopping/apps/productDetailPage/product_detail_page_view.dart';
import 'package:druto_shopping/apps/widgets/custom_text_widget.dart';
import 'package:druto_shopping/general/constants/constants.dart';
import 'package:druto_shopping/general/utils/colors.dart';
import 'package:druto_shopping/general/utils/config.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';

import '../../../general/constants/urls.dart';
import '../../../general/utils/dimensions.dart';
import '../../all_products_page/screens/all_products_view_page.dart';
import '../../drawerScreen/screens/drawer_screen.dart';
import '../../widgets/shimmer_effect_widget.dart';
import '../models/exclusive_product_model.dart';
import '../widgets/carousel_slider_widget.dart';
import '../widgets/headingwidget.dart';
import '../widgets/product_view_item_widget.dart';
import '../widgets/products_view_widget.dart';

class HomePage extends ConsumerWidget {
  int pageIndex = 0;
  HomePage({Key? key}) : super(key: key);
  final TextEditingController _searchController = TextEditingController();

  AllProducts? allProducts;
  List<Product>? product;
  List<CategoriesModel>? categoryItem;
  ExclusiveProductModel? exclusiveProducts;

  List<CarouselItemModel> carousel_item = [
    CarouselItemModel(
        bg: 'https://media.istockphoto.com/photos/what-you-wear-should-make-you-feel-free-and-comfortable-picture-id1297633356?b=1&k=20&m=1297633356&s=170667a&w=0&h=JqUBNLHnDv9SXcULeGmSL3RHVFn1fOGwdsVJbGtFg0o=',
        discountrate: '15%'),
    CarouselItemModel(
        bg: 'https://images.unsplash.com/photo-1609357605129-26f69add5d6e?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=387&q=80',
        discountrate: '15%'),
    CarouselItemModel(
        bg: 'https://images.unsplash.com/photo-1609357605129-26f69add5d6e?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=387&q=80',
        discountrate: '15%')
  ];

  List<ProductsModel> popular_item = [
    ProductsModel(
        discountPrice: '15%',
        name: 'Menz Shirt',
        image:
            'https://image.shutterstock.com/image-photo/mens-clothing-set-boots-watch-600w-1427016581.jpg',
        newprice: '\$120',
        oldprice: '\$150',
        rating: '5'),
    ProductsModel(
        discountPrice: '15%',
        name: 'Womens',
        image:
            'https://images.unsplash.com/photo-1595777457583-95e059d581b8?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=483&q=80',
        newprice: '\$120',
        oldprice: '\$150',
        rating: '7'),
    ProductsModel(
        discountPrice: '10%',
        name: 'Kidz',
        image:
            'https://images.pexels.com/photos/1620760/pexels-photo-1620760.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=1',
        newprice: '\$120',
        oldprice: '\$150',
        rating: '7'),
    ProductsModel(
        discountPrice: '10%',
        name: 'Shoes',
        image:
            'https://images.unsplash.com/photo-1542291026-7eec264c27ff?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=870&q=80',
        newprice: '\$120',
        oldprice: '\$150',
        rating: '7'),
  ];

  @override
  Widget build(BuildContext context, WidgetRef ref) {
    final catList = ref.watch(listProvider);
    Config().init(context);
    final category1 = ref.watch(categoryItems);
    final getBrand = ref.watch(getBrands);
    final getProducts = ref.watch(getallProductss);
    final getTrendy = ref.watch(getTrendyProducts);

    final getExclusive = ref.watch(getExclusiveProducts);

    return Scaffold(
      drawer: DrawerScreen(),
      appBar: AppBar(
        elevation: 0,
        centerTitle: true,
        backgroundColor: Theme.of(context).colorScheme.primary,
        actions: [
          Image(
            image: AssetImage('assets/images/appbar_action_icon.png'),
          ),
        ],
        title: const Image(
          image: AssetImage('assets/images/homepage_main_icon.png'),
        ),
        leading: Builder(builder: (context) {
          return InkWell(
            onTap: () {
              Scaffold.of(context).openDrawer();
              print("object");
            },
            child: const Image(
              image:
                  AssetImage('assets/images/homepage_appbarleading_icon.png'),
            ),
          );
        }),
      ),
      body: SafeArea(
        child: ListView(
          physics: BouncingScrollPhysics(),
          children: [
            Column(
              children: [
                Stack(
                  children: [
                    Container(
                      width: Config.screenWidth,
                      //color: Colors.blue,
                      color: Theme.of(context).scaffoldBackgroundColor,
                      height: Config.screenHeight! * 0.09,
                    ),
                    Container(
                      width: Config.screenWidth,
                      color: Theme.of(context).colorScheme.primary,
                      height: Config.screenHeight! * 0.032,
                    ),
                    Positioned(
                      left: Dimensions.paddingSizeLarge,
                      right: Dimensions.paddingSizeLarge,
                      child: Container(
                        decoration: BoxDecoration(
                          color: ColorResources.COLOR_WHITE,
                          borderRadius: BorderRadius.circular(10),
                          boxShadow: const [
                            BoxShadow(
                              blurRadius: 5,
                              color: Colors.grey,
                              spreadRadius: 1,
                              offset: Offset(4, 4),
                            ),
                          ],
                        ),
                        child: TextFormField(
                          cursorColor:
                              Theme.of(context).colorScheme.onPrimary,
                          controller: _searchController,
                          style: TextStyle(
                              color: Theme.of(context).colorScheme.onPrimary),
                          decoration: InputDecoration(
                            border: InputBorder.none,
                            hintStyle: TextStyle(
                                color: Theme.of(context).colorScheme.primary),
                            prefixIcon: Icon(Icons.search),
                            prefixIconColor:
                                Theme.of(context).colorScheme.primary,
                            contentPadding: EdgeInsets.only(top: 16),
                            hintText: 'Search Here...',
                          ),
                        ),
                      ),
                    ),
                  ],
                ),
                //   spaceVertical(percentange: 0.01),
                CarouselSliderBuilderWidget(carousel_item: carousel_item),
                spaceVertical(percentange: 0.04),
                DivHeadingWidget(
                  title: 'Categories',
                  Ontap: () {
                    Navigator.pushNamed(
                      context,
                      '/categoriesdetailspage',
                      arguments: categories_item,
                    );
                    // Navigator.of(context).push(MaterialPageRoute(builder: (context) => CategoriesDetailsPage(list:  ),));
                  },
                ),
                spaceVertical(percentange: 0.020),
                SizedBox(
                  height: Config.screenHeight! * 0.23,
                  child: category1.when(
                    data: (data) {
                      return ListView.builder(
                        scrollDirection: Axis.horizontal,
                        itemCount: data.data!.category!.length,
                        itemBuilder: (BuildContext context, int index) {
                          return Column(
                            children: [
                              Expanded(
                                flex: 2,
                                child: GestureDetector(
                                  onTap: () {},
                                  child: Container(
                                    alignment: Alignment.center,
                                    margin: EdgeInsets.all(
                                      Config.screenWidth! * 0.02,
                                    ),

                                    width: Config.screenWidth! *
                                        0.22, //Config.screenWidth! * 0.1,
                                    decoration: BoxDecoration(
                                      color: ColorResources.COLOR_WHITE,
                                      shape: BoxShape.circle,
                                      boxShadow: [
                                        BoxShadow(
                                          color: ColorResources.COLOR_BLACK
                                              .withOpacity(0.4),
                                          offset: Offset(0, 2),
                                          spreadRadius: 0.4,
                                          blurRadius: 0.4,
                                        )
                                      ],
                                    ),

                                    child: Container(
                                      alignment: Alignment.center,
                                      decoration: BoxDecoration(
                                        shape: BoxShape.circle,
                                        image: DecorationImage(
                                          image: NetworkImage(
                                            Urls.baseUrlForImage +
                                                data.data!.category![index]
                                                    .photo!,
                                          ),
                                          fit: BoxFit.fill,
                                        ),
                                      ),
                                    ),
                                  ),
                                ),
                              ),
                              spaceVertical(
                                percentange: 0.01,
                              ),
                              Expanded(
                                flex: 1,
                                child: CustomTextWidget(
                                  title: data.data!.category![index].title!,
                                  textstyle: Theme.of(context)
                                      .textTheme
                                      .headline1!
                                      .copyWith(
                                        fontSize: Config.screenWidth! * 0.05,
                                        fontWeight: FontWeight.w400,
                                      ),
                                ),
                              ),
                            ],
                          );
                        },
                      );
                    },
                    error: (error, s) => Text('An error found'),
                    loading: () => ListView.builder(
                      scrollDirection: Axis.horizontal,
                      shrinkWrap: true,
                      itemCount: 4,
                      itemBuilder: (context, index) {
                        return ShimmerEffectWidget(
                          child: Container(
                            margin: EdgeInsets.all(
                              Config.screenWidth! * 0.02,
                            ),
                            width: Config.screenWidth! * 0.22,
                            height: Config.screenWidth! * 0.22,
                            alignment: Alignment.topCenter,
                            decoration: BoxDecoration(
                              shape: BoxShape.circle,
                              color: Colors.amber,
                            ),
                          ),
                        );
                      },
                    ),
                  ),
                ),
                DivHeadingWidget(
                  title: 'Choose Brands',
                  Ontap: () {},
                ),
                spaceVertical(percentange: 0.02),
                SizedBox(
                  height: Config.screenHeight! * 0.14,
                  child: getBrand.when(
                    data: (data) => ListView.builder(
                      scrollDirection: Axis.horizontal,
                      itemCount: data.data!.length,
                      itemBuilder: (BuildContext context, int index) {
                        return GestureDetector(
                          onTap: () {},
                          child: Container(
                            alignment: Alignment.center,
                            margin: EdgeInsets.all(
                              Config.screenWidth! * 0.02,
                            ),

                            // height: Config.screenHeight! *
                            //     0.27, //Config.screenHeight! * 0.1,
                            width: Config.screenWidth! *
                                0.22, //Config.screenWidth! * 0.1,
                            decoration: BoxDecoration(
                              color: ColorResources.COLOR_WHITE,
                              shape: BoxShape.circle,
                              boxShadow: [
                                BoxShadow(
                                    color: ColorResources.COLOR_BLACK
                                        .withOpacity(0.4),
                                    offset: Offset(0, 2),
                                    spreadRadius: 0.4,
                                    blurRadius: 0.4)
                              ],
                            ),

                            child: Container(
                              alignment: Alignment.center,
                              height: Config.screenHeight! * 0.23,
                              width: Config.screenWidth! * 0.23,
                              decoration: BoxDecoration(
                                shape: BoxShape.circle,
                                image: DecorationImage(
                                  fit: BoxFit.cover,
                                  image: NetworkImage(
                                    Urls.baseUrlForImage +
                                        data.data![index].photo!,
                                  ),
                                ),
                              ),
                            ),
                          ),
                        );
                      },
                    ),
                    error: (error, s) => Text('Error found'),
                    loading: () => ListView.builder(
                      scrollDirection: Axis.horizontal,
                      shrinkWrap: true,
                      itemCount: 4,
                      itemBuilder: (context, index) {
                        return ShimmerEffectWidget(
                          child: Container(
                            margin: EdgeInsets.all(
                              Config.screenWidth! * 0.02,
                            ),
                            width: Config.screenWidth! * 0.22,
                            height: Config.screenWidth! * 0.22,
                            alignment: Alignment.topCenter,
                            decoration: BoxDecoration(
                              shape: BoxShape.circle,
                              color: Colors.amber,
                            ),
                          ),
                        );
                      },
                    ),
                  ),
                )
              ],
            ),
            spaceVertical(percentange: 0.03),
            DivHeadingWidget(title: 'Popular', Ontap: () {}),
            spaceVertical(percentange: 0.03),

            Padding(
              padding: EdgeInsets.symmetric(
                  horizontal: Config.screenWidth! * 0.03),
              child: SizedBox(
                height: Config.screenHeight! * 0.33,
                child: ListView.builder(
                  scrollDirection: Axis.horizontal,
                  itemCount: popular_item.length,
                  itemBuilder: (context, index) => Padding(
                    padding: EdgeInsets.symmetric(
                        horizontal: Config.screenWidth! * 0.01),
                    child: ProductItemCustomWidget(
                      ontap: () {
                        Navigator.pushNamed(context, '/productdetailpage',
                            arguments: popular_item[index]);
                      },
                      index: index,
                      list: popular_item,
                    ),
                  ),
                ),
              ),
            ),
            SizedBox(
              height: Config.screenHeight! * 0.004,
            ),

            //here
            spaceVertical(
              percentange: 0.04,
            ),
            DivHeadingWidget(
                title: 'Exclusive',
                Ontap: () {
                  Navigator.of(context).push(
                    MaterialPageRoute(
                      builder: (context) => ExclusiveOffersPageView(
                        products: exclusiveProducts!,
                      ),
                    ),
                  );
                }),
            spaceVertical(
              percentange: 0.02,
            ),
            Padding(
              padding: const EdgeInsets.symmetric(horizontal: 10.0),
              child: SizedBox(
                height: Config.screenHeight! * 0.34,
                child: Container(
                  height: Config.screenHeight! * 0.34,
                  child: getExclusive.when(
                    data: (data) => ListView.builder(
                      scrollDirection: Axis.horizontal,
                      itemCount: data.data!.length,
                      itemBuilder: (context, index) => Padding(
                        padding: EdgeInsets.symmetric(
                            horizontal: Config.screenWidth! * 0.01),
                        child: Container(
                          decoration: BoxDecoration(
                            borderRadius: BorderRadius.circular(10),
                            border: Border.all(
                                color: ColorResources.DIVIDER, width: 2),
                          ),
                          child: Column(
                            children: [
                              Expanded(
                                flex: 2,
                                child: GestureDetector(
                                  onTap: () {},
                                  child: Container(
                                    padding: EdgeInsets.only(
                                        top: Config.screenHeight! * 0.01),
                                    child: Column(
                                      children: [
                                        Row(
                                          mainAxisAlignment:
                                              MainAxisAlignment.spaceBetween,
                                          children: [
                                            Container(
                                              alignment: Alignment.center,
                                              height: Config.screenHeight! *
                                                  0.035,
                                              width:
                                                  Config.screenWidth! * 0.09,
                                              decoration: const BoxDecoration(
                                                  borderRadius:
                                                      BorderRadius.only(
                                                    topRight:
                                                        Radius.circular(10),
                                                    bottomRight:
                                                        Radius.circular(10),
                                                  ),
                                                  color: ColorResources
                                                      .THEME_APPBAR),
                                              child: CustomTextWidget(
                                                title: data.data![index]
                                                    .discountPrice!,
                                                textstyle: Theme.of(context)
                                                    .textTheme
                                                    .subtitle1!
                                                    .copyWith(
                                                      fontSize: Config
                                                              .screenWidth! *
                                                          0.042,
                                                      fontWeight:
                                                          FontWeight.w400,
                                                    ),
                                              ),
                                            ),
                                            GestureDetector(
                                              onTap: () {},
                                              child: const Padding(
                                                padding: EdgeInsets.only(
                                                    right: 4.0),
                                                child: Icon(
                                                  Icons.favorite,
                                                  color: Colors.red,
                                                  size: 30,
                                                ),
                                              ),
                                            ),
                                          ],
                                        ),
                                      ],
                                    ),
                                    height: Config.screenHeight! * 0.21,
                                    width: Config.screenWidth! * 0.5,
                                    decoration: BoxDecoration(
                                      borderRadius: const BorderRadius.only(
                                        topLeft: Radius.circular(10),
                                        topRight: Radius.circular(10),
                                      ),
                                      color: ColorResources.COLOR_WHITE,
                                      image: DecorationImage(
                                        fit: BoxFit.cover,
                                        image: NetworkImage(
                                          Urls.baseUrlForImage +
                                              data.data![index].image!,
                                        ),
                                      ),
                                    ),
                                  ),
                                ),
                              ),
                              Expanded(
                                flex: 1,
                                child: Container(
                                  width: Config.screenWidth! * 0.5,
                                  height: Config.screenHeight! * 0.12,
                                  decoration: const BoxDecoration(
                                    color: ColorResources.ON_SECONDARY,
                                    borderRadius: BorderRadius.only(
                                      bottomLeft: Radius.circular(10),
                                      bottomRight: Radius.circular(10),
                                    ),
                                  ),
                                  child: Padding(
                                    padding: EdgeInsets.symmetric(
                                      horizontal: Config.screenHeight! * .02,
                                    ),
                                    child: Column(
                                      children: [
                                        Row(
                                          mainAxisAlignment:
                                              MainAxisAlignment.spaceBetween,
                                          children: [
                                            CustomTextWidgets(
                                              title: data
                                                  .data![index].productName!,
                                              fontsize:
                                                  Config.screenWidth! * 0.036,
                                              fontweight: FontWeight.w400,
                                            ),
                                            Row(
                                              children: [
                                                Icon(
                                                  Icons.star,
                                                  color: ColorResources
                                                      .PRIMARY_COLOR,
                                                  size: Config.screenWidth! *
                                                      0.04,
                                                ),
                                                CustomTextWidgets(
                                                  title: '( 5 )',
                                                  fontsize:
                                                      Config.screenWidth! *
                                                          00.028,
                                                  fontweight: FontWeight.w400,
                                                ),
                                              ],
                                            )
                                          ],
                                        ),
                                        SizedBox(
                                          height: Config.screenHeight! * 0.01,
                                        ),
                                        Row(
                                          mainAxisAlignment:
                                              MainAxisAlignment.spaceBetween,
                                          children: [
                                            CustomTextWidgets(
                                                title:
                                                    data.data![index].price!,
                                                fontsize:
                                                    Config.screenWidth! *
                                                        0.030,
                                                fontcolor: Colors.red,
                                                fontweight: FontWeight.w500),
                                            CustomTextWidgets(
                                                textDecoration: TextDecoration
                                                    .lineThrough,
                                                title: data
                                                    .data![index].totalPrice!,
                                                fontsize:
                                                    Config.screenWidth! *
                                                        00.030,
                                                fontweight: FontWeight.w400)
                                          ],
                                        ),
                                        SizedBox(
                                          height: Config.screenHeight! * 0.01,
                                        ),
                                        GestureDetector(
                                          onTap: () {},
                                          child: Container(
                                            padding: const EdgeInsets.all(4),
                                            height:
                                                Config.screenHeight! * 0.036,
                                            width: Config.screenWidth! * 0.20,
                                            decoration: BoxDecoration(
                                                color: ColorResources
                                                    .PRIMARY_COLOR,
                                                borderRadius:
                                                    BorderRadius.circular(4)),
                                            child: Row(
                                              children: [
                                                Icon(Icons.shopping_cart,
                                                    color: ColorResources
                                                        .COLOR_BLACK,
                                                    size:
                                                        Config.screenWidth! *
                                                            0.04),
                                                CustomTextWidgets(
                                                    title: ' Add to cart',
                                                    fontsize:
                                                        Config.screenWidth! *
                                                            0.026,
                                                    fontweight:
                                                        FontWeight.w400)
                                              ],
                                            ),
                                          ),
                                        ),
                                      ],
                                    ),
                                  ),
                                ),
                              ),
                            ],
                          ),
                        ),
                      ),
                    ),
                    error: (error, stackTrace) => Text(error.toString()),
                    loading: () => Text('data'),
                  ),
                ),
              ),
            ),
            spaceVertical(
              percentange: 0.04,
            ),
            DivHeadingWidget(
              title: 'Trending Deals ',
              Ontap: () {},
            ),
            spaceVertical(
              percentange: 0.02,
            ),
            SizedBox(
              height: Config.screenHeight! * 0.18,
              child: getTrendy.when(
                  data: ((data) => ListView.builder(
                        scrollDirection: Axis.horizontal,
                        itemCount: data.data!.length,
                        itemBuilder: (context, index) => Card(
                          shape: RoundedRectangleBorder(
                            borderRadius: BorderRadius.circular(10.0),
                          ),
                          child: GestureDetector(
                            onTap: () {},
                            child: Container(
                              decoration: BoxDecoration(
                                image: DecorationImage(
                                  image: NetworkImage(
                                      Urls.baseUrlForImage +
                                          data.data![index].image!,
                                      scale: 3),
                                ),
                              ),
                              width: Config.screenWidth! * 0.6,
                              alignment: Alignment.center,
                              padding:
                                  EdgeInsets.all(Config.screenWidth! * 0.01),
                              child: Container(
                                padding: EdgeInsets.all(
                                    Config.screenWidth! * 0.01),
                                height: Config.screenHeight! * 0.14,
                                width: Config.screenWidth! * 0.34,
                                alignment: Alignment.centerLeft,
                                decoration: BoxDecoration(
                                  color: ColorResources.COLOR_BLACK
                                      .withOpacity(0.5),
                                  borderRadius: BorderRadius.circular(10),
                                ),
                                child: Column(
                                  crossAxisAlignment:
                                      CrossAxisAlignment.start,
                                  children: [
                                    spaceVertical(percentange: 0.01),
                                    CustomTextWidget(
                                      title: 'Super Flash Sale',
                                      textstyle: Theme.of(context)
                                          .textTheme
                                          .headline1!
                                          .copyWith(
                                            fontSize:
                                                Config.screenWidth! * 0.04,
                                            fontWeight: FontWeight.w600,
                                            color: ColorResources.COLOR_WHITE,
                                          ),
                                    ),
                                    spaceVertical(percentange: 0.01),
                                    CustomTextWidget(
                                      title:
                                          data.data![index].discountPrice! +
                                              '% off',
                                      textstyle: Theme.of(context)
                                          .textTheme
                                          .headline1!
                                          .copyWith(
                                            fontSize:
                                                Config.screenWidth! * 0.04,
                                            fontWeight: FontWeight.w600,
                                            color: ColorResources.COLOR_WHITE,
                                          ),
                                    ),
                                    spaceVertical(percentange: 0.01),
                                    GestureDetector(
                                      onTap: () {
                                        Navigator.pushNamed(
                                          context, '/trendydetails',
                                          // arguments: trending_item[index]);
                                        );
                                      },
                                      child: Container(
                                        alignment: Alignment.center,
                                        child: CustomTextWidget(
                                          title: 'See More',
                                          textstyle: Theme.of(context)
                                              .textTheme
                                              .headline1!
                                              .copyWith(
                                                fontSize:
                                                    Config.screenWidth! *
                                                        0.04,
                                                fontWeight: FontWeight.w600,
                                                color: ColorResources
                                                    .COLOR_BLACK,
                                              ),
                                        ),
                                        height: Config.screenHeight! * 0.03,
                                        width: Config.screenWidth! * 0.25,
                                        decoration: BoxDecoration(
                                          color: ColorResources.COLOR_WHITE,
                                          borderRadius:
                                              BorderRadius.circular(6),
                                        ),
                                      ),
                                    )
                                  ],
                                ),
                              ),
                            ),
                          ),
                          color: Colors.blue,
                        ),
                      )),
                  error: ((error, s) => Text(error.toString())),
                  loading: (() => ListView.builder(
                        scrollDirection: Axis.horizontal,
                        shrinkWrap: true,
                        itemCount: 4,
                        itemBuilder: (context, index) {
                          return ShimmerEffectWidget(
                            child: Container(
                              margin: EdgeInsets.all(
                                Config.screenWidth! * 0.02,
                              ),
                              width: Config.screenWidth! * 0.22,
                              height: Config.screenWidth! * 0.22,
                              alignment: Alignment.topCenter,
                              decoration: BoxDecoration(
                                shape: BoxShape.circle,
                                color: Colors.amber,
                              ),
                            ),
                          );
                        },
                      ))),
            ),
            spaceVertical(
              percentange: 0.04,
            ),
            DivHeadingWidget(
              title: 'Products ',
              Ontap: () {
                Navigator.of(context).push(
                  MaterialPageRoute(
                    builder: (context) => AllProdutsViewPage(
                      products: allProducts!,
                    ),
                  ),
                );
              },
            ),
            spaceVertical(percentange: 0.02),
            getProducts.when(
              data: ((data) {
                allProducts = data;
                return GridView(
                  padding: EdgeInsets.only(
                    left: Config.screenWidth! * 0.03,
                    right: Config.screenWidth! * 0.03,
                  ),
                  shrinkWrap: true,
                  physics: const NeverScrollableScrollPhysics(),
                  scrollDirection: Axis.vertical,
                  gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
                    crossAxisSpacing: Config.screenWidth! * 0.03,
                    mainAxisSpacing: Config.screenWidth! * 0.03,
                    childAspectRatio: 1 / 1.4,
                    crossAxisCount: 2,
                  ),
                  children: data.data!.product!
                      .map((e) => productsView(
                            e,
                            context,
                            () {
                              Navigator.of(context).push(MaterialPageRoute(
                                builder: ((context) => ProductDetailPageView(
                                      value: e,
                                    )),
                              ));
                            },
                          ))
                      .toList(),
                );
              }),
              error: ((error, s) => Text(
                    error.toString(),
                  )),
              loading: (() => CircularProgressIndicator()),
            ),
            spaceVertical(
              percentange: 0.051,
            ),
          ],
        ),
      ),
    );
  }
}