import 'dart:io';

import 'package:dropdown_button2/dropdown_button2.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:generp/Notifiers/crmProvider/addNewLeadsandProspectsProvider.dart';
import 'package:generp/Utils/app_colors.dart';
import 'package:generp/Utils/commonWidgets.dart';
import 'package:generp/Utils/dropdownTheme.dart';
import 'package:provider/provider.dart';

import '../../Models/crmModels/GetDistrictOnStateResponse.dart';
import '../../Models/crmModels/GetSegmentOnTeamResponse.dart';
import '../../Models/crmModels/GetSourceOnReferenceResponse.dart';
import '../../Models/crmModels/GetSubLocOnDistrictResponse.dart';
import '../../Models/crmModels/crmNewLeadsProspectsViewResponse.dart';
import 'addLeadProductScreen.dart';

class Addleadsprospectsscreen extends StatefulWidget {
  const Addleadsprospectsscreen({super.key});

  @override
  State<Addleadsprospectsscreen> createState() =>
      _AddleadsprospectsscreenState();
}

class _AddleadsprospectsscreenState extends State<Addleadsprospectsscreen> {
  Dropdowntheme ddtheme = Dropdowntheme();
  int _currentStep = 0;
  final _formKey = GlobalKey<FormState>();

  // Controllers to store form data
  final _nameController = TextEditingController();
  final _emailController = TextEditingController();
  final _addressController = TextEditingController();

  @override
  void dispose() {
    _nameController.dispose();
    _emailController.dispose();
    _addressController.dispose();
    super.dispose();
  }

  void _nextStep() {
    if (_formKey.currentState!.validate()) {
      if (_currentStep < 2) {
        setState(() {
          _currentStep += 1;
        });
      } else {
        // Submit form data
        _submitForm();
      }
    }
  }

  void _previousStep() {
    if (_currentStep > 0) {
      setState(() {
        _currentStep -= 1;
      });
    }
  }

  void _submitForm() {
    // Simulate form submission (e.g., print data or send to server)
    print('Form Submitted:');
    print('Name: ${_nameController.text}');
    print('Email: ${_emailController.text}');
    print('Address: ${_addressController.text}');
    ScaffoldMessenger.of(context).showSnackBar(
      const SnackBar(content: Text('Form submitted successfully!')),
    );
  }

  @override
  void initState() {
    super.initState();
    WidgetsBinding.instance.addPostFrameCallback((_) async {
      final provider = Provider.of<Addnewleadsandprospectsprovider>(
        context,
        listen: false,
      );
      provider.crmAddLeadsView(context, "team");
    });
  }

  @override
  Widget build(BuildContext context) {
    return Consumer<Addnewleadsandprospectsprovider>(
      builder: (context, provider, child) {
        return WillPopScope(
          onWillPop: () async {
            provider.resetForm();
            return true;
          },
          child: SafeArea(
            top: false,
            bottom: Platform.isIOS ? false : true,
            child: Scaffold(
              resizeToAvoidBottomInset: true,
              backgroundColor: AppColors.scaffold_bg_color,
              appBar: appbar2New(
                context,
                "Add Leads and Prospect",
                provider.resetForm,
                const SizedBox(width: 0),
                0xFFFFFFFF,
              ),
              //
              body: Form(
                key: _formKey,
                child: Stepper(
                  margin: EdgeInsets.symmetric(horizontal: 0, vertical: 0),
                  type: StepperType.horizontal,
                  currentStep: _currentStep,
                  onStepContinue: _nextStep,
                  onStepCancel: _previousStep,
                  onStepTapped: (value) {
                    print(value);
                    setState(() {
                      _currentStep = value;
                    });
                  },
                  connectorColor: WidgetStatePropertyAll(AppColors.app_blue),
                  stepIconBuilder: (stepIndex, stepState) {
                    return CircleAvatar(
                      radius: 12,
                      backgroundColor: stepIndex <= _currentStep
                          ? AppColors.app_blue
                          : Colors.grey[300],
                    );
                  },
                  steps: [
                    Step(

                      label: Text("Step 1",style: TextStyle(
                          fontSize: 12
                      )),
                      title: const Text(''),
                      isActive: _currentStep >= 0,
                      content: Container(
                        padding: EdgeInsets.symmetric(
                          horizontal: 10,
                          vertical: 10,
                        ),

                        decoration: BoxDecoration(
                          color: Colors.white,
                          borderRadius: BorderRadius.circular(16),
                        ),
                        child: Column(
                          crossAxisAlignment: CrossAxisAlignment.start,
                          children: [
                            TextWidget(context, "Salutation"),
                            DropdownButtonHideUnderline(
                              child: Row(
                                children: [
                                  Expanded(
                                    child: DropdownButton2<String>(
                                      isExpanded: true,
                                      hint: const Row(
                                        children: [
                                          Expanded(
                                            child: Text(
                                              'Select Salutation',
                                              style: TextStyle(fontSize: 14),
                                              overflow: TextOverflow.ellipsis,
                                            ),
                                          ),
                                        ],
                                      ),
                                      items:
                                      provider.salutationList
                                          .map(
                                            (slist) =>
                                            DropdownMenuItem<String>(
                                              value: slist,
                                              child: Text(
                                                slist ?? '',
                                                style: const TextStyle(
                                                  fontSize: 14,
                                                ),
                                                overflow:
                                                TextOverflow.ellipsis,
                                              ),
                                            ),
                                      )
                                          .toList(),
                                      value: provider.selectedSalutation,
                                      onChanged: (value) {
                                        if (value != null) {
                                          provider.selectedSalutation = value;
                                        }
                                      },
                                      buttonStyleData: ddtheme.buttonStyleData,
                                      iconStyleData: ddtheme.iconStyleData,
                                      menuItemStyleData:
                                      ddtheme.menuItemStyleData,
                                      dropdownStyleData:
                                      ddtheme.dropdownStyleData,
                                    ),
                                  ),
                                ],
                              ),
                            ),
                            errorWidget(context, provider.salutationError),

                            textControllerWidget(
                              context,
                              provider.companyNameController,
                              "Company Name",
                              "Enter Company Name",
                              provider.onChangeCompanyName,
                              TextInputType.name,
                              false,
                              null,
                            ),
                            errorWidget(context, provider.companynameError),

                            textControllerWidget(
                              context,
                              provider.contactPersonNameController,
                              "Contact Person Name",
                              "Enter Name",
                              provider.onChangeContactPersonName,
                              TextInputType.name,
                              false,
                              null,
                            ),
                            errorWidget(context, provider.nameError),

                            textControllerWidget(
                              context,
                              provider.mobileController,
                              "Mobile Number",
                              "Enter Mobile Number",
                              provider.onChangemobile,
                              TextInputType.phone,
                              false,
                              FilteringTextInputFormatter.digitsOnly,
                            ),
                            errorWidget(context, provider.mobileError),



                            textControllerWidget(
                              context,
                              provider.customerMailIdController,
                              "Customer Email Id",
                              "Enter Email Id",
                              provider.onChangemailId,
                              TextInputType.emailAddress,
                              false,
                              null,
                            ),
                            errorWidget(context, provider.mailIdError),


                            textControllerWidget(
                              context,
                              provider.designationController,
                              "Customer Designation",
                              "Enter Designation",
                              provider.onChangedesignation,
                              TextInputType.text,
                              false,
                              null,
                            ),
                            errorWidget(context, provider.designationError),
                          ],
                        ),
                      ),
                    ),
                    Step(
                      label: Text("Step 2",style: TextStyle(
                          fontSize: 12
                      )),
                      title: const Text(''),
                      isActive: _currentStep >= 1,
                      content: Container(
                        padding: EdgeInsets.symmetric(
                          horizontal: 10,
                          vertical: 10,
                        ),

                        decoration: BoxDecoration(
                          color: Colors.white,
                          borderRadius: BorderRadius.circular(16),
                        ),
                        child: Column(
                          crossAxisAlignment: CrossAxisAlignment.start,
                          children: [
                            textControllerWidget(
                              context,
                              provider.alternateMobileController,
                              "Alternate Mobile Number",
                              "Enter Alternate Mobile Number",
                              provider.onChangeAlternatemobile,
                              TextInputType.phone,
                              false,
                              FilteringTextInputFormatter.digitsOnly,
                            ),

                            errorWidget(context, provider.AlternatemobileError),

                            textControllerWidget(
                              context,
                              provider.telephoneController,
                              "Telephone Number",
                              "Enter Telephone Number",
                              provider.onChangeTelephone,
                              TextInputType.phone,
                              false,
                              FilteringTextInputFormatter.digitsOnly,
                            ),
                            errorWidget(context, provider.TelephoneError),
                            TextWidget(context, "Source"),
                            DropdownButtonHideUnderline(
                              child: Row(
                                children: [
                                  Expanded(
                                    child: DropdownButton2<Sources>(
                                      hint: Text(
                                        "Select Source",
                                        style: TextStyle(fontSize: 14),
                                      ),
                                      items:
                                      provider.sourcesList
                                          .map(
                                            (slist) =>
                                            DropdownMenuItem<Sources>(
                                              value: slist,
                                              child: Text(
                                                slist.name!,
                                                style: TextStyle(
                                                  fontSize: 14,
                                                ),
                                              ),
                                            ),
                                      )
                                          .toList(),
                                      value: provider.selectedSources,
                                      onChanged: (Sources? value) {
                                        if (value != null) {
                                          if (provider.sourcesList.isNotEmpty) {
                                            provider.selectedSources = value;
                                            provider.selectedSourcesId =
                                            value!.id!;
                                            provider.selectedSourcesValue =
                                            value!.name!;
                                            provider
                                                .crmLeadListSourceOnReferenceAPIFunction(
                                              context,
                                              "",
                                              provider.selectedSourcesId,
                                            );
                                          }
                                        }
                                      },
                                      isExpanded: true,
                                      buttonStyleData: ddtheme.buttonStyleData,
                                      iconStyleData: ddtheme.iconStyleData,
                                      menuItemStyleData:
                                      ddtheme.menuItemStyleData,
                                      dropdownStyleData:
                                      ddtheme.dropdownStyleData,
                                    ),
                                  ),
                                ],
                              ),
                            ),
                            errorWidget(context, provider.sourceError),
                            TextWidget(context, "Reference"),
                            DropdownButtonHideUnderline(
                              child: Row(
                                children: [
                                  Expanded(
                                    child: DropdownButton2<References>(
                                      hint: Text(
                                        "Select Reference",
                                        style: TextStyle(fontSize: 14),
                                      ),
                                      items:
                                      provider.referencesList
                                          .map(
                                            (slist) =>
                                            DropdownMenuItem<References>(
                                              value: slist,
                                              child: Text(
                                                slist.name!,
                                                style: TextStyle(
                                                  fontSize: 14,
                                                ),
                                              ),
                                            ),
                                      )
                                          .toList(),
                                      value: provider.selectedReference,
                                      onChanged: (References? value) {
                                        if (value != null) {
                                          if (provider
                                              .referencesList
                                              .isNotEmpty) {
                                            provider.selectedReference = value;
                                            provider.selectedReferenceId =
                                            value!.id!;
                                            provider.selectedReferenceValue =
                                            value!.name!;
                                          }
                                        }
                                      },
                                      isExpanded: true,
                                      buttonStyleData: ddtheme.buttonStyleData,
                                      iconStyleData: ddtheme.iconStyleData,
                                      menuItemStyleData:
                                      ddtheme.menuItemStyleData,
                                      dropdownStyleData:
                                      ddtheme.dropdownStyleData,
                                    ),
                                  ),
                                ],
                              ),
                            ),
                            errorWidget(context, provider.referenceError),
                            TextWidget(context, "Team"),
                            DropdownButtonHideUnderline(
                              child: Row(
                                children: [
                                  Expanded(
                                    child: DropdownButton2<Teams>(
                                      hint: Text(
                                        "Select Team",
                                        style: TextStyle(fontSize: 14),
                                      ),
                                      items:
                                      provider.teamsList
                                          .map(
                                            (slist) =>
                                            DropdownMenuItem<Teams>(
                                              value: slist,
                                              child: Text(
                                                slist.name!,
                                                style: TextStyle(
                                                  fontSize: 14,
                                                ),
                                              ),
                                            ),
                                      )
                                          .toList(),
                                      value: provider.selectedTeams,
                                      onChanged: (Teams? value) {
                                        if (value != null) {
                                          if (provider.teamsList.isNotEmpty) {
                                            provider.selectedTeams = value;
                                            provider.selectedTeamsId = value!.id!;
                                            provider.selectedTeamsValue =
                                            value!.name!;
                                            provider
                                                .crmLeadListSegmentOnTeamAPIFunction(
                                              context,
                                              "",
                                              provider.selectedTeamsId,
                                            );
                                          }
                                        }
                                      },
                                      isExpanded: true,
                                      buttonStyleData: ddtheme.buttonStyleData,
                                      iconStyleData: ddtheme.iconStyleData,
                                      menuItemStyleData:
                                      ddtheme.menuItemStyleData,
                                      dropdownStyleData:
                                      ddtheme.dropdownStyleData,
                                    ),
                                  ),
                                ],
                              ),
                            ),
                            errorWidget(context, provider.teamsError),
                            TextWidget(context, "Segment"),
                            DropdownButtonHideUnderline(
                              child: Row(
                                children: [
                                  Expanded(
                                    child: DropdownButton2<Segments>(
                                      hint: Text(
                                        "Select Segment",
                                        style: TextStyle(fontSize: 14),
                                      ),
                                      items:
                                      provider.segmentsList
                                          .map(
                                            (slist) =>
                                            DropdownMenuItem<Segments>(
                                              value: slist,
                                              child: Text(
                                                slist.name!,
                                                style: TextStyle(
                                                  fontSize: 14,
                                                ),
                                              ),
                                            ),
                                      )
                                          .toList(),
                                      value: provider.selectedSegment,
                                      onChanged: (Segments? value) {
                                        if (value != null) {
                                          if (provider.segmentsList.isNotEmpty) {
                                            provider.selectedSegment = value;
                                            provider.selectedSegmentId =
                                            value!.id!;
                                            provider.selectedSegmentValue =
                                            value!.name!;
                                          }
                                        }
                                      },
                                      isExpanded: true,
                                      buttonStyleData: ddtheme.buttonStyleData,
                                      iconStyleData: ddtheme.iconStyleData,
                                      menuItemStyleData:
                                      ddtheme.menuItemStyleData,
                                      dropdownStyleData:
                                      ddtheme.dropdownStyleData,
                                    ),
                                  ),
                                ],
                              ),
                            ),
                            errorWidget(context, provider.segmentsError),
                          ],
                        ),
                      ),
                    ),
                    Step(
                      label: Text("Step 3",style: TextStyle(
                        fontSize: 12
                      ),),
                      title: const Text(''),
                      isActive: _currentStep >= 2,
                      content: Column(
                        crossAxisAlignment: CrossAxisAlignment.start,
                        children: [
                          Container(
                            padding: EdgeInsets.symmetric(
                              horizontal: 10,
                              vertical: 10,
                            ),

                            decoration: BoxDecoration(
                              color: Colors.white,
                              borderRadius: BorderRadius.circular(16),
                            ),
                            child: Column(
                              children: [
                                InkResponse(
                                  onTap: () async {
                                    var res = await Navigator.push(
                                      context,
                                      MaterialPageRoute(
                                        builder:
                                            (context) =>
                                                Addleadproductscreen(

                                            ),
                                        settings: RouteSettings(
                                          name: 'Generatequotationaddeditproduct',
                                        ),
                                      ),
                                    );
                                    if (res != null) {
                                      print("result ${res}");

                                    }
                                  },
                                  child: Container(
                                    margin: const EdgeInsets.symmetric(
                                      vertical: 10,
                                    ),
                                    height: 45,
                                    width: MediaQuery
                                        .of(context)
                                        .size
                                        .width,
                                    decoration: BoxDecoration(
                                      color: const Color(0xFFE6F6FF),
                                      borderRadius: BorderRadius.circular(12),
                                      border: Border.all(
                                        color: AppColors.app_blue,
                                        width: 0.5,
                                      ),
                                    ),
                                    child: Center(
                                      child: Text(
                                        "+ Add Product",
                                        style: TextStyle(
                                          fontFamily: "JakartaMedium",
                                          color: AppColors.app_blue,
                                        ),
                                      ),
                                    ),
                                  ),
                                ),
                              ],
                            ),
                          ),
                          SizedBox(height: 10),
                          Container(
                            padding: EdgeInsets.symmetric(
                              horizontal: 10,
                              vertical: 10,
                            ),

                            decoration: BoxDecoration(
                              color: Colors.white,
                              borderRadius: BorderRadius.circular(16),
                            ),
                            child: Column(
                              crossAxisAlignment: CrossAxisAlignment.start,
                              children: [
                                TextWidget(context, "State"),
                                DropdownButtonHideUnderline(
                                  child: Row(
                                    children: [
                                      Expanded(
                                        child: DropdownButton2<States>(
                                          hint: Text(
                                            "Select State",
                                            style: TextStyle(fontSize: 14),
                                          ),
                                          items:
                                          provider.statesList
                                              .map(
                                                (slist) =>
                                                DropdownMenuItem<States>(
                                                  value: slist,
                                                  child: Text(
                                                    slist.name!,
                                                    style: TextStyle(
                                                      fontSize: 14,
                                                    ),
                                                  ),
                                                ),
                                          )
                                              .toList(),
                                          value: provider.selectedStates,
                                          onChanged: (States? value) {
                                            if (value != null) {
                                              if (provider
                                                  .statesList
                                                  .isNotEmpty) {
                                                provider.selectedStates = value;
                                                provider.selectedStatesId =
                                                value!.id!;
                                                provider.selectedStatesValue =
                                                value!.name!;
                                                if (provider
                                                    .districtsList
                                                    .isNotEmpty) {
                                                  provider.districtsList.clear();
                                                  // provider.selectedDistricts = null;
                                                  provider.selectedDistrictId =
                                                  null;
                                                  provider.selectedDistrictValue =
                                                  "";
                                                }
                                                provider
                                                    .crmLeadListDistrictsOnStateAPIFunction(
                                                  context,
                                                  "",
                                                  provider.selectedStatesId,
                                                );
                                              }
                                            }
                                          },
                                          isExpanded: true,
                                          buttonStyleData:
                                          ddtheme.buttonStyleData,
                                          iconStyleData: ddtheme.iconStyleData,
                                          menuItemStyleData:
                                          ddtheme.menuItemStyleData,
                                          dropdownStyleData:
                                          ddtheme.dropdownStyleData,
                                        ),
                                      ),
                                    ],
                                  ),
                                ),
                                errorWidget(context, provider.statesError),
                                TextWidget(context, "District"),
                                DropdownButtonHideUnderline(
                                  child: Row(
                                    children: [
                                      Expanded(
                                        child: DropdownButton2<Districts>(
                                          hint: Text(
                                            "Select District",
                                            style: TextStyle(fontSize: 14),
                                          ),
                                          items:
                                          provider.districtsList
                                              .map(
                                                (slist) =>
                                                DropdownMenuItem<
                                                    Districts
                                                >(
                                                  value: slist,
                                                  child: Text(
                                                    slist.district!,
                                                    style: TextStyle(
                                                      fontSize: 14,
                                                    ),
                                                  ),
                                                ),
                                          )
                                              .toList(),
                                          value: provider.selectedDistricts,
                                          onChanged: (Districts? value) {
                                            if (value != null) {
                                              if (provider
                                                  .districtsList
                                                  .isNotEmpty) {
                                                provider.selectedDistricts =
                                                    value;
                                                provider.selectedDistrictId =
                                                value!.id!;
                                                provider.selectedDistrictValue =
                                                value!.district!;
                                                if (provider
                                                    .subLocationsList
                                                    .isNotEmpty) {
                                                  provider.subLocationsList
                                                      .clear();
                                                  // provider.selectedSubLocations =
                                                  //     null;
                                                  provider.selectedSubLocationId =
                                                  null;
                                                  provider
                                                      .selectedSubLocationValue =
                                                  "";
                                                }
                                                provider
                                                    .crmLeadListSubLocOnDistrictAPIFunction(
                                                  context,
                                                  "",
                                                  provider.selectedDistrictId,
                                                );
                                              }
                                            }
                                          },
                                          isExpanded: true,
                                          buttonStyleData:
                                          ddtheme.buttonStyleData,
                                          iconStyleData: ddtheme.iconStyleData,
                                          menuItemStyleData:
                                          ddtheme.menuItemStyleData,
                                          dropdownStyleData:
                                          ddtheme.dropdownStyleData,
                                        ),
                                      ),
                                    ],
                                  ),
                                ),
                                errorWidget(context, provider.districtsError),
                                TextWidget(context, "Sub Location"),
                                DropdownButtonHideUnderline(
                                  child: Row(
                                    children: [
                                      Expanded(
                                        child: DropdownButton2<SubLocations>(
                                          hint: Text(
                                            "Select Sub Location",
                                            style: TextStyle(fontSize: 14),
                                          ),
                                          items:
                                          provider.subLocationsList
                                              .map(
                                                (slist) =>
                                                DropdownMenuItem<
                                                    SubLocations
                                                >(
                                                  value: slist,
                                                  child: Text(
                                                    slist.subLocality!,
                                                    style: TextStyle(
                                                      fontSize: 14,
                                                    ),
                                                  ),
                                                ),
                                          )
                                              .toList(),
                                          value: provider.selectedSubLocations,
                                          onChanged: (SubLocations? value) {
                                            if (value != null) {
                                              if (provider
                                                  .subLocationsList
                                                  .isNotEmpty) {
                                                provider.selectedSubLocations =
                                                    value;
                                                provider.selectedSubLocationId =
                                                value!.id!;
                                                provider
                                                    .selectedSubLocationValue =
                                                value!.subLocality!;
                                              }
                                            }
                                          },
                                          isExpanded: true,
                                          buttonStyleData:
                                          ddtheme.buttonStyleData,
                                          iconStyleData: ddtheme.iconStyleData,
                                          menuItemStyleData:
                                          ddtheme.menuItemStyleData,
                                          dropdownStyleData:
                                          ddtheme.dropdownStyleData,
                                        ),
                                      ),
                                    ],
                                  ),
                                ),
                                errorWidget(context, provider.subLocError),
                                TextWidget(context, "Lead Status"),
                                DropdownButtonHideUnderline(
                                  child: Row(
                                    children: [
                                      Expanded(
                                        child: DropdownButton2<String>(
                                          isExpanded: true,
                                          hint: const Row(
                                            children: [
                                              Expanded(
                                                child: Text(
                                                  'Select Lead Status',
                                                  style: TextStyle(fontSize: 14),
                                                  overflow: TextOverflow.ellipsis,
                                                ),
                                              ),
                                            ],
                                          ),
                                          items:
                                          <String>['Cold', 'Hot', 'Warm']
                                              .map(
                                                (value) =>
                                                DropdownMenuItem<String>(
                                                  value: value,
                                                  child: Text(
                                                    value ?? '',
                                                    style: const TextStyle(
                                                      fontSize: 14,
                                                    ),
                                                    overflow: TextOverflow.ellipsis,
                                                  ),
                                                ),
                                          )
                                              .toList(),
                                          value: provider.selectedLeadStatus,
                                          onChanged: (String? newValue) {
                                            setState(() {
                                              provider.selectedLeadStatus = newValue!;
                                            });
                                          },
                                          buttonStyleData: ddtheme.buttonStyleData,
                                          iconStyleData: ddtheme.iconStyleData,
                                          menuItemStyleData: ddtheme.menuItemStyleData,
                                          dropdownStyleData: ddtheme.dropdownStyleData,
                                        ),
                                      ),
                                    ],
                                  ),
                                ),
                                errorWidget(context, provider.leadStatusError),
                                textControllerWidget(
                                  context,
                                  provider.addressController,
                                  "Address",
                                  "Enter Address ",
                                  provider.onChangeaddress,
                                  TextInputType.streetAddress,
                                  false,
                                  null,
                                ),

                                errorWidget(context, provider.addressError),
                              ],
                            ),
                          ),
                        ],
                      ),
                    ),
                  ],
                  controlsBuilder: (context, details) {
                    // return Row(
                    //   children: [
                    //     ElevatedButton(
                    //       onPressed: () {
                    //         setState(() {
                    //           if (_currentStep == 0) {
                    //             _currentStep = 1;
                    //           } else if (_currentStep == 1) {
                    //             _currentStep = 2;
                    //           } else {
                    //             _currentStep = 0;
                    //           }
                    //         });
                    //         details.onStepContinue;
                    //       },
                    //       child: Text(_currentStep == 2 ? 'Submit' : 'Next'),
                    //     ),
                    //     const SizedBox(width: 10),
                    //     if (_currentStep > 0)
                    //       TextButton(
                    //         onPressed: () {
                    //           setState(() {
                    //             if (_currentStep == 2) {
                    //               _currentStep = 1;
                    //             } else if (_currentStep == 1) {
                    //               _currentStep = 0;
                    //             } else {
                    //               _currentStep = 2;
                    //             }
                    //           });
                    //           details.onStepCancel;
                    //         },
                    //         child: const Text('Back'),
                    //       ),
                    //   ],
                    // );
                    return Column(
                      children: [
                        if (_currentStep == 2) ...[
                          InkResponse(
                            onTap: () {
                              setState(() {
                                if (_currentStep == 0) {
                                  _currentStep = 1;
                                } else if (_currentStep == 1) {
                                  _currentStep = 2;
                                } else {
                                  _currentStep = 0;
                                }
                              });

                              provider.crmAddNewLeadsAndProspectsAPIFunction(
                                  context,
                                  "",
                                  provider.selectedEmployeesId,
                                  provider.selectedSalutation,
                                  provider.selectedDistrictId,
                                  provider.selectedStatesId,
                                  provider.selectedSegmentId,
                                  provider.selectedSourcesId,
                                  provider.selectedReferenceId,
                                  provider.selectedReferenceId,
                                  provider.selectedSubLocationId,
                                  provider.selectedLeadStatus,
                                  {});
                              details.onStepContinue;
                            },
                            child: Container(
                              height: 45,
                              alignment: Alignment.center,
                              margin: EdgeInsets.symmetric(
                                horizontal: 10,
                                vertical: 10,
                              ),
                              padding: EdgeInsets.symmetric(
                                horizontal: 10,
                                vertical: 5,
                              ),
                              decoration: BoxDecoration(
                                color: AppColors.app_blue,
                                borderRadius: BorderRadius.circular(15),
                              ),
                              child: Text(
                                "Submit",
                                style: TextStyle(
                                  fontSize: 15,
                                  fontFamily: "JakartaMedium",
                                  color: Colors.white,
                                ),
                              ),
                            ),
                          ),
                        ] else
                          ...[
                            InkResponse(
                              onTap: () {
                                setState(() {
                                  if (_currentStep == 0) {
                                    _currentStep = 1;
                                  } else if (_currentStep == 1) {
                                    _currentStep = 2;
                                  } else {
                                    _currentStep = 0;
                                  }
                                });
                                details.onStepContinue;
                              },
                              child: Container(
                                height: 45,
                                alignment: Alignment.center,
                                margin: EdgeInsets.symmetric(
                                  horizontal: 10,
                                  vertical: 10,
                                ),
                                padding: EdgeInsets.symmetric(
                                  horizontal: 10,
                                  vertical: 5,
                                ),
                                decoration: BoxDecoration(
                                  color: AppColors.app_blue,
                                  borderRadius: BorderRadius.circular(15),
                                ),
                                child: Text(
                                  "Proceed to Next Step",
                                  textAlign: TextAlign.start,
                                  style: TextStyle(
                                    fontSize: 15,
                                    fontFamily: "JakartaMedium",
                                    color: Colors.white,
                                  ),
                                ),
                              ),
                            ),
                          ],
                        if (_currentStep > 0) ...[
                          TextButton(
                            onPressed: () {
                              setState(() {
                                if (_currentStep == 2) {
                                  _currentStep = 1;
                                } else if (_currentStep == 1) {
                                  _currentStep = 0;
                                } else {
                                  _currentStep = 2;
                                }
                              });
                              details.onStepCancel;
                            },
                            child: Text(
                              'Back',
                              style: TextStyle(
                                color: AppColors.app_blue,
                                fontSize: 14,
                              ),
                            ),
                          ),
                        ],
                      ],
                    );
                  },
                ),
              ),
            ),
          ),
        );
      },
    );
  }
}
