import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_form_builder/flutter_form_builder.dart';
import 'package:form_builder_validators/form_builder_validators.dart';
import 'package:intl/intl.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:unit2/bloc/offline/offline_passo/building/additional_items_offline/additional_items_offline_bloc.dart';
import 'package:unit2/bloc/offline/offline_passo/building/appraisal_offline/bldg_appraisal_offline_bloc.dart';
import 'package:unit2/bloc/offline/offline_passo/building/building_and_structure/building_and_structure_bloc.dart';
import 'package:unit2/model/offline/offline_profile.dart';
import 'package:unit2/screens/offline/passo/building/add/add_building.dart';
import 'package:unit2/screens/offline/passo/building/add/additional_items.dart';
import 'package:unit2/screens/offline/passo/building/edit/property_owner_info_edit.dart';
import 'package:unit2/theme-data.dart/form-style.dart';

import '../../../../../model/passo/additional_items.dart';
import '../../../../../model/passo/building_and_structure.dart';
import '../../../../../widgets/passo/custom_button.dart';

class PropertyAppraisalOfflinePage extends StatefulWidget {
  final VoidCallback NextBtn;
  final VoidCallback PrevBtn;
  final OfflineProfile offlineProfile;

  PropertyAppraisalOfflinePage(this.NextBtn, this.PrevBtn, this.offlineProfile);

  @override
  _PropertyAppraisalOfflinePage createState() =>
      _PropertyAppraisalOfflinePage();
}

class _PropertyAppraisalOfflinePage
    extends State<PropertyAppraisalOfflinePage> {
  double depRate = 0;

  double _depRate = 0;

  double assessment_level = 0;
  bool isTaxable = false;
  bool isExempt = false;
  String _memoranda = '';
  final focus = FocusNode();

  String assessmentLevel(marketValues, property_class) {
    final marketValue = marketValues;
    switch (property_class) {
      case 'Residential':
        if (marketValue < 175000) {
          // setState(() {
          //   assessment_level = 0;
          // });
          return '0 ';
        } else if (marketValue < 300000 && marketValue > 175000) {
          // setState(() {
          //   assessment_level = 0.10;
          // });
          return '10 ';
        } else if (marketValue < 500000 && marketValue > 300000) {
          // setState(() {
          //   assessment_level = 0.20;
          // });
          return '20 ';
        } else if (marketValue < 750000 && marketValue > 500000) {
          // setState(() {
          //   assessment_level = 0.25;
          // });
          return '25 ';
        } else if (marketValue < 1000000 && marketValue > 750000) {
          // setState(() {
          //   assessment_level = 0.30;
          // });
          return '30 ';
        } else if (marketValue < 2000000 && marketValue > 1000000) {
          // setState(() {
          //   assessment_level = 0.35;
          // });
          return '35 ';
        } else if (marketValue < 5000000 && marketValue > 2000000) {
          // setState(() {
          //   assessment_level = 0.40;
          // });
          return '40 ';
        } else if (marketValue < 10000000 && marketValue > 5000000) {
          // setState(() {
          //   assessment_level = 0.50;
          // });
          return '50 ';
        } else if (marketValue > 10000000) {
          // setState(() {
          //   assessment_level = 0.60;
          // });
          return '60 ';
        }
        break;
      case 'Agricultural':
        if (marketValue < 300000) {
          // setState(() {
          //   assessment_level = 0.45;
          // });
          return '45 ';
        } else if (marketValue < 500000 && marketValue > 300000) {
          // setState(() {
          //   assessment_level = 0.50;
          // });
          return '50 ';
        } else if (marketValue < 750000 && marketValue > 5000000) {
          // setState(() {
          //   assessment_level = 0.55;
          // });
          return '55 ';
        } else if (marketValue < 1000000 && marketValue > 750000) {
          // setState(() {
          //   assessment_level = 0.60;
          // });
          return '60 ';
        } else if (marketValue < 2000000 && marketValue > 1000000) {
          // setState(() {
          //   assessment_level = 0.65;
          // });
          return '65 ';
        } else if (marketValue > 2000000) {
          // setState(() {
          //   assessment_level = 0.70;
          // });
          return '70 ';
        }
        break;
      case 'Commercial':
        if (marketValue < 300000) {
          // setState(() {
          //   assessment_level = 0.30;
          // });
          return '30 ';
        } else if (marketValue < 500000 && marketValue > 300000) {
          // setState(() {
          //   assessment_level = 0.35;
          // });
          return '35 ';
        } else if (marketValue < 750000 && marketValue > 500000) {
          // setState(() {
          //   assessment_level = 0.40;
          // });
          return '40 ';
        } else if (marketValue < 1000000 && marketValue > 750000) {
          // setState(() {
          //   assessment_level = 0.50;
          // });
          return '50 ';
        } else if (marketValue < 2000000 && marketValue > 1000000) {
          // setState(() {
          //   assessment_level = 0.60;
          // });
          return '60 ';
        } else if (marketValue < 5000000 && marketValue > 2000000) {
          // setState(() {
          //   assessment_level = 0.70;
          // });
          return '70 ';
        } else if (marketValue < 10000000 && marketValue > 5000000) {
          // setState(() {
          //   assessment_level = 0.75;
          // });
          return '75 ';
        } else if (marketValue > 10000000) {
          // setState(() {
          //   assessment_level = 0.80;
          // });
        }
        break;
      case 'Industrial':
        if (marketValue < 300000) {
          // setState(() {
          //   assessment_level = 0.30;
          // });
          return '30 ';
        } else if (marketValue < 500000 && marketValue > 300000) {
          // setState(() {
          //   assessment_level = 0.35;
          // });
          return '35 ';
        } else if (marketValue < 750000 && marketValue > 500000) {
          // setState(() {
          //   assessment_level = 0.40;
          // });
          return '40 ';
        } else if (marketValue < 1000000 && marketValue > 750000) {
          // setState(() {
          //   assessment_level = 0.50;
          // });
          return '50 ';
        } else if (marketValue < 2000000 && marketValue > 1000000) {
          // setState(() {
          //   assessment_level = 0.60;
          // });
          return '60 ';
        } else if (marketValue < 5000000 && marketValue > 2000000) {
          // setState(() {
          //   assessment_level = 0.70;
          // });
          return '70 ';
        } else if (marketValue < 10000000 && marketValue > 5000000) {
          // setState(() {
          //   assessment_level = 0.75;
          // });
          return '75 ';
        } else if (marketValue > 10000000) {
          // setState(() {
          //   assessment_level = 0.80;
          // });
          return '80 ';
        }
        break;
      case 'Mineral':
        break;
      case 'Timberland':
        if (marketValue < 300000) {
          // setState(() {
          //   assessment_level = 0.45;
          // });
          return '45 ';
        } else if (marketValue < 500000 && marketValue > 300000) {
          // setState(() {
          //   assessment_level = 0.50;
          // });
          return '50 ';
        } else if (marketValue < 750000 && marketValue > 500000) {
          // setState(() {
          //   assessment_level = 0.55;
          // });
          return '55 ';
        } else if (marketValue < 1000000 && marketValue > 750000) {
          // setState(() {
          //   assessment_level = 0.60;
          // });
          return '60 ';
        } else if (marketValue < 2000000 && marketValue > 1000000) {
          // setState(() {
          //   assessment_level = 0.65;
          // });
          return '65 ';
        } else if (marketValue < 2000000) {
          // setState(() {
          //   assessment_level = 0.70;
          // });
          return '70 ';
        }
        break;
      default:
    }
    return '';
  }

  double assessmentValue(marketValues, property_class) {
    final marketValue = marketValues;
    switch (property_class) {
      case 'Residential':
        if (marketValue < 175000) {
          // setState(() {
          //   assessment_level = 0;
          // });
          return marketValue * 0;
        } else if (marketValue < 300000 && marketValue > 175000) {
          // setState(() {
          //   assessment_level = 0.10;
          // });
          return marketValue * 0.10;
        } else if (marketValue < 500000 && marketValue > 300000) {
          // setState(() {
          //   assessment_level = 0.20;
          // });
          return marketValue * 0.20;
        } else if (marketValue < 750000 && marketValue > 500000) {
          // setState(() {
          //   assessment_level = 0.25;
          // });
          return marketValue * 0.25;
        } else if (marketValue < 1000000 && marketValue > 750000) {
          // setState(() {
          //   assessment_level = 0.30;
          // });
          return marketValue * 0.30;
        } else if (marketValue < 2000000 && marketValue > 1000000) {
          // setState(() {
          //   assessment_level = 0.35;
          // });
          return marketValue * 0.35;
        } else if (marketValue < 5000000 && marketValue > 2000000) {
          // setState(() {
          //   assessment_level = 0.40;
          // });
          return marketValue * 0.40;
        } else if (marketValue < 10000000 && marketValue > 5000000) {
          // setState(() {
          //   assessment_level = 0.50;
          // });
          return marketValue * 0.50;
        } else if (marketValue > 10000000) {
          // setState(() {
          //   assessment_level = 0.60;
          // });
          return marketValue * 0.60;
        }
        break;
      case 'Agricultural':
        if (marketValue < 300000) {
          // setState(() {
          //   assessment_level = 0.45;
          // });
          return marketValue * 0.45;
        } else if (marketValue < 500000 && marketValue > 300000) {
          // setState(() {
          //   assessment_level = 0.50;
          // });
          return marketValue * 0.50;
        } else if (marketValue < 750000 && marketValue > 5000000) {
          // setState(() {
          //   assessment_level = 0.55;
          // });
          return marketValue * 0.55;
        } else if (marketValue < 1000000 && marketValue > 750000) {
          // setState(() {
          //   assessment_level = 0.60;
          // });
          return marketValue * 0.60;
        } else if (marketValue < 2000000 && marketValue > 1000000) {
          // setState(() {
          //   assessment_level = 0.65;
          // });
          return marketValue * 0.65;
        } else if (marketValue > 2000000) {
          // setState(() {
          //   assessment_level = 0.70;
          // });
          return marketValue * 0.70;
        }
        break;
      case 'Commercial':
        if (marketValue < 300000) {
          // setState(() {
          //   assessment_level = 0.30;
          // });
          return marketValue * 0.30;
        } else if (marketValue < 500000 && marketValue > 300000) {
          // setState(() {
          //   assessment_level = 0.35;
          // });
          return marketValue * 0.35;
        } else if (marketValue < 750000 && marketValue > 500000) {
          // setState(() {
          //   assessment_level = 0.40;
          // });
          return marketValue * 0.40;
        } else if (marketValue < 1000000 && marketValue > 750000) {
          // setState(() {
          //   assessment_level = 0.50;
          // });
          return marketValue * 0.50;
        } else if (marketValue < 2000000 && marketValue > 1000000) {
          // setState(() {
          //   assessment_level = 0.60;
          // });
          return marketValue * 0.60;
        } else if (marketValue < 5000000 && marketValue > 2000000) {
          // setState(() {
          //   assessment_level = 0.70;
          // });
          return marketValue * 0.70;
        } else if (marketValue < 10000000 && marketValue > 5000000) {
          // setState(() {
          //   assessment_level = 0.75;
          // });
          return marketValue * 0.75;
        } else if (marketValue > 10000000) {
          // setState(() {
          //   assessment_level = 0.80;
          // });
        }
        break;
      case 'Industrial':
        if (marketValue < 300000) {
          // setState(() {
          //   assessment_level = 0.30;
          // });
          return marketValue * 0.30;
        } else if (marketValue < 500000 && marketValue > 300000) {
          // setState(() {
          //   assessment_level = 0.35;
          // });
          return marketValue * 0.35;
        } else if (marketValue < 750000 && marketValue > 500000) {
          // setState(() {
          //   assessment_level = 0.40;
          // });
          return marketValue * 0.40;
        } else if (marketValue < 1000000 && marketValue > 750000) {
          // setState(() {
          //   assessment_level = 0.50;
          // });
          return marketValue * 0.50;
        } else if (marketValue < 2000000 && marketValue > 1000000) {
          // setState(() {
          //   assessment_level = 0.60;
          // });
          return marketValue * 0.60;
        } else if (marketValue < 5000000 && marketValue > 2000000) {
          // setState(() {
          //   assessment_level = 0.70;
          // });
          return marketValue * 0.70;
        } else if (marketValue < 10000000 && marketValue > 5000000) {
          // setState(() {
          //   assessment_level = 0.75;
          // });
          return marketValue * 0.75;
        } else if (marketValue > 10000000) {
          // setState(() {
          //   assessment_level = 0.80;
          // });
          return marketValue * 0.80;
        }
        break;
      case 'Mineral':
        break;
      case 'Timberland':
        if (marketValue < 300000) {
          // setState(() {
          //   assessment_level = 0.45;
          // });
          return marketValue * 0.45;
        } else if (marketValue < 500000 && marketValue > 300000) {
          // setState(() {
          //   assessment_level = 0.50;
          // });
          return marketValue * 0.50;
        } else if (marketValue < 750000 && marketValue > 500000) {
          // setState(() {
          //   assessment_level = 0.55;
          // });
          return marketValue * 0.55;
        } else if (marketValue < 1000000 && marketValue > 750000) {
          // setState(() {
          //   assessment_level = 0.60;
          // });
          return marketValue * 0.60;
        } else if (marketValue < 2000000 && marketValue > 1000000) {
          // setState(() {
          //   assessment_level = 0.65;
          // });
          return marketValue * 0.65;
        } else if (marketValue < 2000000) {
          // setState(() {
          //   assessment_level = 0.70;
          // });
          return marketValue * 0.70;
        }
        break;
      default:
    }
    return 0;
  }

  _calculateMarketValue(
      List<AdditionalItems> items, List<BldgAndStructure> bldg) {
    double add_sum = 0;
    double product = 1;
    double bldg_sum = 0;

    for (AdditionalItems value in items) {
      add_sum += double.parse(value.adjustedMarketVal.toString());
    }

    for (BldgAndStructure value in bldg) {
      bldg_sum += double.parse(value.adjustedMarketValue.toString());
    }

    return add_sum + bldg_sum;
  }

  double _totalMarketValue(items) {
    double total = 0;
    items.forEach((row) {
      total += row.adjustedMarketVal;
    });
    return total;
  }

  double _totalMarketValueBLDG(items) {
    double total = 0;
    items.forEach((row) {
      total += double.parse(row.adjustedMarketValue);
    });
    return total;
  }

  // calculateMarketValue(buildingCost, additionalItems, dep) {
  //   double sum = 0;
  //   double depreciation = 0;
  //   double total = 0;

  //   sum = buildingCost + calculateAdditionalItems(additionalItems);

  //   depreciation = sum * dep;

  //   total = sum - depreciation;

  //   return total;
  // }

  // calculateDepCost(buildingCost, additionalItems, dep) {
  //   double sum = 0;
  //   double depreciation = 0;
  //   double total = 0;

  //   sum = buildingCost + calculateAdditionalItems(additionalItems);

  //   depreciation = sum * dep;

  //   total = sum - depreciation;

  //   return depreciation;
  // }

  @override
  Widget build(BuildContext context) {
    final width = MediaQuery.of(context).size.width;
    return Scaffold(
        body: BlocConsumer<AdditionalItemsOfflineBloc,
            AdditionalItemsOfflineState>(
      listener: (context, state) {},
      builder: (context, state) {
        if (state is AdditionalItemsLoaded) {
          final addItem = state.addItem;
          return BlocConsumer<BuildingAndStructureBloc,
              BuildingAndStructureState>(
            listener: (context, state) {
              // TODO: implement listener
            },
            builder: (context, state) {
              if (state is BuildingAndStructureLoaded) {
                return SingleChildScrollView(
                  padding: const EdgeInsets.all(20),
                  child: Column(
                    children: [
                      Container(
                        margin: const EdgeInsets.only(
                            left: 0, top: 20, right: 0, bottom: 20),
                        child: const Text('PROPERTY APPRAISAL',
                            style: TextStyle(
                                fontWeight: FontWeight.bold, fontSize: 20),
                            textAlign: TextAlign.left),
                      ),
                      Row(
                        mainAxisSize: MainAxisSize.min,
                        children: [
                          Expanded(
                            flex: 1,
                            child: SingleChildScrollView(
                                scrollDirection: Axis.horizontal,
                                child: Column(
                                  mainAxisSize: MainAxisSize.min,
                                  children: [
                                    Container(
                                      margin: const EdgeInsets.only(
                                          left: 0,
                                          top: 20,
                                          right: 0,
                                          bottom: 20),
                                      child: const Text('BUILDING & STRUCTURE',
                                          style: TextStyle(
                                              fontWeight: FontWeight.bold,
                                              fontSize: 15),
                                          textAlign: TextAlign.left),
                                    ),
                                    DataTable(
                                      columnSpacing:
                                          MediaQuery.of(context).size.width / 4,
                                      columns: [
                                        const DataColumn(
                                          label: Text('Building Core'),
                                        ),
                                        const DataColumn(
                                          label: Text(''),
                                        ),
                                        const DataColumn(
                                          label: Text('Market Value'),
                                        ),
                                      ],
                                      rows: [
                                        ...state.bldgAndStructure
                                            .map((dataRow) {
                                          return DataRow(cells: [
                                            DataCell(Text(dataRow.structType!)),
                                            DataCell(Text("")),
                                            DataCell(Text(
                                              NumberFormat.currency(
                                                locale: 'en-PH',
                                                symbol: "₱",
                                              ).format(double.parse(dataRow
                                                  .adjustedMarketValue
                                                  .toString()!)),
                                            ))
                                          ]);
                                        }),
                                        DataRow(cells: [
                                          DataCell(Text('Total',
                                              style: TextStyle(
                                                  fontWeight: FontWeight.bold,
                                                  fontSize: 15,
                                                  color: Colors.red))),
                                          DataCell(Text('')),
                                          DataCell(
                                            Text(
                                                NumberFormat.currency(
                                                  locale: 'en-PH',
                                                  symbol: "₱",
                                                ).format(_totalMarketValueBLDG(
                                                    state.bldgAndStructure)),
                                                style: TextStyle(
                                                    fontWeight: FontWeight.bold,
                                                    fontSize: 15,
                                                    color: Colors.red)),
                                          )
                                        ]),
                                      ],
                                    )
                                  ],
                                )),
                          ),
                        ],
                      ),
                      Row(
                        children: [
                          Expanded(
                            flex: 1,
                            child: SingleChildScrollView(
                                scrollDirection: Axis.horizontal,
                                child: Column(
                                  children: [
                                    Container(
                                      margin: const EdgeInsets.only(
                                          left: 0,
                                          top: 20,
                                          right: 0,
                                          bottom: 20),
                                      child: const Text('ADDITIONAL ITEMS',
                                          style: TextStyle(
                                              fontWeight: FontWeight.bold,
                                              fontSize: 15),
                                          textAlign: TextAlign.left),
                                    ),
                                    DataTable(
                                        columnSpacing:
                                            MediaQuery.of(context).size.width /
                                                3,
                                        columns: const [
                                          DataColumn(
                                            label: Text('Additional Item'),
                                          ),
                                          DataColumn(
                                            label: Text(''),
                                          ),
                                          DataColumn(
                                            label: Text('Market Value'),
                                          ),
                                        ],
                                        rows: [
                                          ...addItem.map((dataRow) {
                                            return DataRow(cells: [
                                              DataCell(
                                                  Text(dataRow.className!)),
                                              DataCell(Text('')),
                                              DataCell(Text(
                                                NumberFormat.currency(
                                                        locale: 'en-PH',
                                                        symbol: "₱")
                                                    .format(double.parse(dataRow
                                                        .marketValue
                                                        .toString()!))
                                                    .toString(),
                                              ))
                                            ]);
                                          }).toList(),
                                          DataRow(
                                              // color: MaterialStateColor.resolveWith(
                                              //     (states) {
                                              //   // Use a color for the DataRow, for example, Colors.blue
                                              //   return Colors.redAccent;
                                              // }),
                                              cells: [
                                                DataCell(Text('Total',
                                                    style: TextStyle(
                                                        fontWeight:
                                                            FontWeight.bold,
                                                        fontSize: 15,
                                                        color: Colors.red))),
                                                DataCell(Text('')),
                                                DataCell(
                                                  Text(
                                                      NumberFormat.currency(
                                                        locale: 'en-PH',
                                                        symbol: "₱",
                                                      ).format(
                                                          _totalMarketValue(
                                                              addItem)),
                                                      style: TextStyle(
                                                          fontWeight:
                                                              FontWeight.bold,
                                                          fontSize: 15,
                                                          color: Colors.red)),
                                                )
                                              ]),
                                        ]),
                                  ],
                                )),
                          ),
                        ],
                      ),
                      Row(
                        children: [
                          Expanded(
                            flex: 1,
                            child: SingleChildScrollView(
                                scrollDirection: Axis.horizontal,
                                child: Column(
                                  children: [
                                    Container(
                                      margin: const EdgeInsets.only(
                                          left: 0,
                                          top: 20,
                                          right: 0,
                                          bottom: 20),
                                      child: const Text('PROPERTY ASSESSMENT',
                                          style: TextStyle(
                                              fontWeight: FontWeight.bold,
                                              fontSize: 15),
                                          textAlign: TextAlign.left),
                                    ),
                                    DataTable(
                                        columnSpacing:
                                            MediaQuery.of(context).size.width /
                                                6,
                                        columns: const [
                                          DataColumn(
                                            label: Text('Actual Use'),
                                          ),
                                          DataColumn(
                                            label: Text('Market Value'),
                                          ),
                                          DataColumn(
                                            label: Text('Ass. Level'),
                                          ),
                                          DataColumn(
                                            label: Text('Ass. Value'),
                                          ),
                                        ],
                                        rows: <DataRow>[
                                          DataRow(
                                            cells: <DataCell>[
                                              DataCell(Text(offlineBldgKey
                                                      .currentState
                                                      ?.value['actual_use'] ??
                                                  "")),
                                              DataCell(Text(NumberFormat
                                                      .currency(
                                                          locale: 'en-PH',
                                                          symbol: "₱")
                                                  .format(_calculateMarketValue(
                                                      addItem,
                                                      state
                                                          .bldgAndStructure)))),
                                              DataCell(
                                                Text(
                                                  assessmentLevel(
                                                      _calculateMarketValue(
                                                          addItem,
                                                          state
                                                              .bldgAndStructure),
                                                      offlineBldgKey
                                                              .currentState
                                                              ?.value[
                                                          'actual_use']),
                                                  style: const TextStyle(
                                                    fontWeight: FontWeight.bold,
                                                    fontSize: 13,
                                                  ),
                                                  textAlign: TextAlign.center,
                                                ),
                                              ),
                                              DataCell(Text(
                                                NumberFormat.currency(
                                                        locale: 'en-PH',
                                                        symbol: "₱")
                                                    .format(double.parse(
                                                      assessmentValue(
                                                              _calculateMarketValue(
                                                                  addItem,
                                                                  state
                                                                      .bldgAndStructure),
                                                              offlineBldgKey
                                                                      .currentState
                                                                      ?.value[
                                                                  'actual_use'])
                                                          .toString(),
                                                    ))
                                                    .toString(),
                                              )),
                                            ],
                                          ),
                                        ])
                                  ],
                                )),
                          ),
                        ],
                      ),
                      const SizedBox(
                        height: 50,
                      ),
                      Row(
                        mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                        children: [
                          CustomButton(
                            icon: const Icon(Icons.chevron_left_rounded,
                                color: Colors.white),
                            onPressed: () {
                              {
                                widget.PrevBtn();
                              }
                              ;
                            },
                          ),
                          CustomButton(
                            icon: const Icon(Icons.chevron_right_rounded,
                                color: Colors.white),
                            onPressed: () async {
                              {
                                // final tempID =
                                //     await SharedPreferences.getInstance();
                                // print(tempID.getInt('tempid'));
                                // context.read<BldgAppraisalOfflineBloc>().add(AddBldgAppraisal(
                                //     id: 1,
                                //     bldgapprDetailsId: tempID.getInt('tempid')!,
                                //     assessedById: '1',
                                //     assessedByName: 'ad',
                                //     dateCreated: '00',
                                //     dateModified: '00',
                                //     unitconstructCost: offlineBldgKey
                                //         .currentState
                                //         ?.value['bldg_type']
                                //         .unitValue,
                                //     buildingCore: 'test',
                                //     unitconstructSubtotal:
                                //         (double.parse(offlineBldgKey.currentState!.value['total_area']) *
                                //                 double.parse(offlineBldgKey
                                //                     .currentState!
                                //                     .value['bldg_type']
                                //                     .unitValue))
                                //             .toString(),
                                //     depreciationRate: depRate.toString(),
                                //     depreciationCost: calculateDepCost(
                                //             (double.parse(offlineBldgKey.currentState!.value['total_area']) *
                                //                 double.parse(offlineBldgKey.currentState?.value['bldg_type'].unitValue)),
                                //             addItem,
                                //             depRate)
                                //         .toString(),
                                //     costAddItems: calculateAdditionalItems(addItem).toString(),
                                //     addItemsSubtotal: calculateAdditionalItems(addItem).toString(),
                                //     totalpercentDepreciation: (depRate * 100).toStringAsFixed(2),
                                //     marketValue: calculateMarketValue((double.parse(offlineBldgKey.currentState!.value['total_area']) * double.parse(offlineBldgKey.currentState!.value['bldg_type'].unitValue)), addItem, depRate).toString(),
                                //     totalArea: offlineBldgKey.currentState!.value['total_area'],
                                //     actualUse: "Residential"));
                                widget.NextBtn();
                              }
                              ;
                            },
                          )
                        ],
                      ),
                    ],
                  ),
                );
              }
              return Container();
            },
          );
        }
        return Container();
      },
    ));
  }
}
