import 'dart:convert';
import 'dart:math' as math;

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:memorias_calculo/src/front/widgets/cubo.dart';
import 'package:memorias_calculo/src/front/widgets/formatters.dart';
import 'package:geolocator/geolocator.dart';
import 'package:http/http.dart' as http;

class CalculadoraEstacionamientoPage extends StatefulWidget {
  final String ciudad;
  final String estado;
  final String pais;

  const CalculadoraEstacionamientoPage({Key? key, required this.ciudad, required this.estado, required this.pais}) : super(key: key);
  
  @override
  _CalculadoraEstacionamientoPageState createState() => _CalculadoraEstacionamientoPageState();
}

class _CalculadoraEstacionamientoPageState extends State<CalculadoraEstacionamientoPage> {
  final TextEditingController _areaController = TextEditingController();
  final TextEditingController _alturaController = TextEditingController();
  final TextEditingController _distMaxController = TextEditingController();
  double _valArea = 0.0;
  double _valAltura = 0.0;
  double _valVolumen = 0.0;
  double _valDistMax = 0.0;
  double _caudalExtraccion = 0.0;
  double _valVelInducida = 0.0;
  double _renovaciones = 0.0;
  double _alturaCiudad = 0.0;
  double _tempCiudad = 0.0;
  double _densidad = 0.0;
  double _superficieVentilada = 0.0;
  double _cantEquipos = 0.0;
  String _unidadArea = "m²";
  String _unidadAltura = "m";
  String _unidadVolumen = "m³";
  String _ubicacion = "";
  String _equipo = "JET-FAN (recomendado)";
  String _modelo = "";
  int _normativa = 0;
  int _intEquipos = 0;
  bool _isLoading = true;
  bool _consultando = false;

  static const List<String> _unidadesArea = ["m²", "ft²"];
  static const List<String> _unidadesAltura = ["m", "ft"];
  static const List<String> _unidadesVolumen = ["m³", "ft³"];
  static const List<String> _equipos = ["JET-FAN (recomendado)", "TUBULARES"];
  static const Map<String, Map<String, double>> _listaEquipos = {
    "JET-FAN (recomendado)" : {
      "TCP-250 (B)"  : 7.3,
      "TCP-250 (A)"  : 8.7,
      "TCP-315 (B)"  : 6.5,
      "TCP-315 (A)"  : 7.7,
      "TCP-400"      : 9.3,
      "TCP/4-450"    : 62,
      "TCP/4-500"    : 86,
      "TCP/6-450"    : 18,
      "TCP/6-500"    : 38,
      "IFHT/4-50N-C" : 47,
      "IFHT/4-75N-C" : 75,
      "IFHT/4-100N-C": 95,
      "IFHT/8-13N-C" : 13,
      "IFHT/8-15N-C" : 15,
      "IFHT/8-24N-C" : 24,
    },
    "TUBULARES" : {
      "RBC-400" : 11.53,
      "RBC-500" : 30.11,
      "RBC-630" : 70.64,
      "RBC-800" : 80.92,
      "RBW-400" : 11.53,
      "RBW-500" : 30.11,
      "RBW-630" : 70.64,
      "RBW-800" : 80.92,
      "TAT-1000/H" : 339.16,
      "TAT-1000/L" : 149.92,
      "TAT-630/H" : 82.45,
      "TAT-630/L" : 43.71,
      "TAT-800/H" : 171.87,
      "TAT-800/L" : 74.93,
      "TTB-250" : 6.69,
      "TTB-315" : 8.54,
      "TTB-400" : 11.00,
      "TTB-500" : 35.89,
      "TTT-400" : 11.00,
      "TTT-500" : 35.89,
    }
  };
  static const List<int> _normativas = [1, 2, 3];

  final List<String> _ubicaciones = [];

  @override
  void initState() {
    super.initState();
    _areaController.text = _valArea.toStringAsFixed(2);
    _alturaController.text = _valAltura.toStringAsFixed(2);
    _distMaxController.text = _valDistMax.toStringAsFixed(2);

    _init();
  }

  Future<void> _init() async{
    bool serviceEnabled;
    LocationPermission permission;

    serviceEnabled = await Geolocator.isLocationServiceEnabled();
    if(!serviceEnabled){
      print("HOLA");
    }

    permission = await Geolocator.checkPermission();
    if(permission == LocationPermission.denied){
      permission = await Geolocator.requestPermission();
      if(permission == LocationPermission.denied){
        print("HOLA 1");
      }
    }

    if(permission == LocationPermission.deniedForever){
      print("HOLA 2");
    }

    final position = await Geolocator.getCurrentPosition();
    final latitud = position.latitude;
    final longitud = position.longitude;

    final url = Uri.https("www.solerpalau.mx", "mdc.qa/altitud.php");
    final res = await http.post(url,
      body: {
        "LAT" : "$latitud",
        "LON" : "$longitud"
      }
    );

    final decoded = jsonDecode(res.body);

    if(decoded["status"] != "OK"){
      print("ERROR");
    }else{
      _alturaCiudad = decoded["results"][0]["elevation"];
    }

    final uri = Uri.parse("https://api.openweathermap.org/data/2.5/weather?lat=$latitud&lon=$longitud&appid=fe3b68585dbadc9da643f5f720edba85&units=metric");
    final resp = await http.get(uri);
    final dec = jsonDecode(resp.body);

    _tempCiudad = dec["main"]["temp"];

    await _readJson();
    _ubicaciones.insert(0, "$latitud, $longitud (Ubicación actual)");
    _ubicacion = _ubicaciones[0];

    _densidad = (1 / ((0.9318 + (0.00341 * _tempCiudad)) * math.exp(0.0001186 * _alturaCiudad))) * 1.2;
    setState(() => _isLoading = false);
  }

  Future<void> _readJson() async{
    String pais = widget.pais.split(" ")[1];
    pais = pais.replaceAll("(", "").replaceAll(")", "");

    final String paisesEstados = await rootBundle.loadString('assets/paises_db_simple.json');
    final String municipios = await rootBundle.loadString('assets/paises_db.json');
    final String munMex = await rootBundle.loadString('municipios_mx.json');

    final paisesEstadosArr = await jsonDecode(paisesEstados);
    final estados = paisesEstadosArr['estados'];

    var munDec;
    if(pais == "MX") munDec = jsonDecode(munMex);
    else munDec = jsonDecode(municipios);

    estados.forEach((estado){
      if(estado["SUCountry"] == pais){
        final estadoCode = estado["SUCode"];
        final estadoName = estado["SUName"];
        if(pais == "MX"){
          final municipiosMX = munDec["c_Municipio"];
          municipiosMX.forEach((municipio){
            if(municipio["c_Estado"] == estadoCode && municipio["Descripción"] != widget.ciudad){
              _ubicaciones.add("${municipio["Descripción"]}, $estadoName ($estadoCode)");
            }
          });
        }else{
          final municipiosINT = munDec[0]["data"];
          municipiosINT.forEach((municipio){
            if(municipio["Country"] == pais && municipio["Subdivision"] != null){
              if(municipio["Subdivision"] == estadoCode && municipio["Name"] != widget.ciudad){
                _ubicaciones.add("${municipio["Name"]}, $estadoName ($estadoCode)");
              }
            }
          });
        }
      }
    });

    _ubicaciones.insert(0, "${widget.ciudad}, ${widget.estado} (Ubicación de la cuenta)");
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: _isLoading ? const Center(
        child: CircularProgressIndicator(),
      ) : LayoutBuilder(
        builder: (context, constraints){
          final parentWidth = constraints.maxWidth;

          double containerWidth = parentWidth > 1440
              ? parentWidth*0.5 : parentWidth > 1280 && parentWidth <= 1440
              ? parentWidth*0.6 : parentWidth > 1080 && parentWidth <= 1280
              ? parentWidth*0.75 : parentWidth > 900 && parentWidth <= 1080
              ? parentWidth*0.8 : parentWidth > 720 && parentWidth <= 900
              ? parentWidth*0.85 : parentWidth > 540 && parentWidth <= 720
              ? parentWidth*0.9 : parentWidth;
          double containerMargin = (parentWidth - containerWidth) / 2;

          return SingleChildScrollView(
            child: Container(
              width: containerWidth,
              margin: EdgeInsets.symmetric(
                horizontal: containerMargin,
              ),
              child: Column(
                children: [
                  const SizedBox(height: 8.0),
                  Container(
                    margin: const EdgeInsets.symmetric(
                      horizontal: 32.0,
                    ),
                    child: Row(
                      children: [
                        TextButton(
                          child: Text(
                            "Memoria de cálculo de ventilación de estacionamientos >",
                            style: GoogleFonts.roboto(
                              fontSize: 16.0,
                              fontWeight: FontWeight.bold,
                              fontStyle: FontStyle.italic,
                            ),
                          ),
                          onPressed: () async{
                            final accion = await showDialog(
                              context: context,
                              barrierDismissible: false,
                              builder: (context) => AlertDialog(
                                title: Text(
                                  "Salir sin guardar",
                                  textAlign: TextAlign.center,
                                  style: GoogleFonts.roboto(
                                    fontWeight: FontWeight.bold,
                                    fontSize: 20.0,
                                    color: Colors.black87,
                                  ),
                                ),
                                content: Text(
                                  "¿Está seguro de salir sin guardar los cambios?",
                                  textAlign: TextAlign.center,
                                  style: GoogleFonts.roboto(
                                    fontSize: 16.0,
                                  ),
                                ),
                                actions: [
                                  TextButton(
                                    child: const Text(
                                      "Salir sin guardar",
                                    ),
                                    onPressed: () => Navigator.pop(context, "salir"),
                                  ),
                                  TextButton(
                                    child: const Text(
                                      "Guardar y salir",
                                    ),
                                    onPressed: () => Navigator.pop(context, "guardar"),
                                  ),
                                  TextButton(
                                    child: const Text(
                                      "Cancelar",
                                    ),
                                    onPressed: () => Navigator.pop(context, "cancelar"),
                                  )
                                ],
                              ),
                            );

                            if(accion == "salir"){
                              Navigator.pop(context);
                            }else if(accion == "guardar"){
                              /*Map<String, Map<String, String>> datos = {
                                "datos": {
                                  "tipoInstalacion" : _tipoInstalacion,
                                  "tipoCampana" : "Campana $_aplicacionCampana $_montajeCampana",
                                  "eqCocina" : _eqCocinaCampana,
                                  "longitud" : "$_valLongitud $_unidadLongitudes",
                                  "ancho" : "$_valAncho $_unidadLongitudes",
                                  "distCapt" : "$_valDistCap $_unidadLongitudes",
                                  "caudalEx" : "${(_caudalExtraccion * _factores[_eqCocinaCampana]!).round()} $_unidadCaudal",
                                  "cauInySug" : "${((_caudalExtraccion * _factores[_eqCocinaCampana]!) * 0.85).round()} $_unidadCaudal",
                                  "velAire" : _tipoInstalacion == "N" ? "$_velocidadAire" : "${_velRec.first}",
                                  "ductoCuadradoCM" : _tipoInstalacion == "N" ? "$_ductoCuadradoCM cm" : _tipoDuctoInstalado == "cuadrado" ? "${_medidaDuctoController.text} cm" : "0 cm",
                                  "ductoCuadradoIN" : _tipoInstalacion == "N" ? "$_ductoCuadradoIN in" : _tipoDuctoInstalado == "cuadrado" ? "${_medidaDuctoController.text} in" : "0 in",
                                  "ductoCircularCM" : _tipoInstalacion == "N" ? "$_ductoCircularCM cm" : _tipoDuctoInstalado == "circular" ? "${_medidaDuctoController.text} cm" : "0 cm",
                                  "ductoCircularIN" : _tipoInstalacion == "N" ? "$_ductoCircularIN in" : _tipoDuctoInstalado == "circular" ? "${_medidaDuctoController.text} in" : "0 in",
                                  "ductoSeleccion" : _tipoInstalacion == "N" ? "$_tipoDucto" : "$_tipoDuctoInstalado",
                                  "unidadesInstalado" : _unidadDucto
                                },
                                if(_confCuad.isNotEmpty)
                                  "campana": _confCuad,
                                if(_cuadricula.isNotEmpty)
                                  "cuadricula": _cuadricula,
                                if(_jsonCalculos.isNotEmpty)
                                  "calculos": { "resultados": _jsonCalculos }
                              };
                              String datosStr = jsonEncode(datos);

                              final guardado = await _cambiarDatos(datosStr);
                              if(guardado){
                                Fluttertoast.showToast(
                                    msg: "El proyecto se guardó satisfactoriamente",
                                    toastLength: Toast.LENGTH_SHORT,
                                    timeInSecForIosWeb: 4,
                                    gravity: ToastGravity.CENTER,
                                    webBgColor: "linear-gradient(to right, #266B1F, #98F58F)"
                                );
                              }else{
                                Fluttertoast.showToast(
                                    msg: "Hubo un error al intentar guardar el proyecto, intentelo de nuevo más tarde.",
                                    toastLength: Toast.LENGTH_SHORT,
                                    timeInSecForIosWeb: 4,
                                    gravity: ToastGravity.CENTER,
                                    webBgColor: "linear-gradient(to right, #b40404, #ff0000)"
                                );
                              }

                              Navigator.pop(context);*/
                            }
                          },
                          style: TextButton.styleFrom(
                            padding: const EdgeInsets.fromLTRB(0.0, 0.0, 8.0, 0.0),
                            minimumSize: const Size(0.0, 0.0),
                            tapTargetSize: MaterialTapTargetSize.shrinkWrap,
                          ),
                        ),
                        const SizedBox(width: 8.0),
                        Expanded(
                          child: Container(
                            padding: const EdgeInsets.fromLTRB(0.0, 0.0, 8.0, 0.0),
                            child: Text(
                              "Extracción en estacionamientos cerrados",
                              maxLines: 1,
                              overflow: TextOverflow.ellipsis,
                              style: GoogleFonts.roboto(
                                fontSize: 16.0,
                                color: Colors.black54,
                                fontWeight: FontWeight.bold,
                                fontStyle: FontStyle.italic,
                              ),
                            ),
                          ),
                        ),
                      ],
                    ),
                  ),
                  const SizedBox(
                    height: 8.0,
                  ),
                  Row(
                    children: [
                      const SizedBox(width: 32.0),
                      Image.asset(
                        "logo.png",
                        width: 64.0,
                      ),
                      Expanded(child: Container()),
                      Image.asset(
                        "logo_completo.png",
                        height: 64.0,
                      ),
                      const SizedBox(width: 32.0),
                    ],
                  ),
                  const SizedBox(
                    height: 32.0,
                  ),
                  Image.asset(
                    "estacionamientos.png",
                    width: 120.0,
                  ),
                  const SizedBox(
                    height: 48.0,
                  ),
                  Container(
                    width: double.infinity,
                    padding: const EdgeInsets.symmetric(
                      horizontal: 32.0,
                    ),
                    child: Text(
                      "Extracción en estacionamientos cerrados".toUpperCase(),
                      textAlign: TextAlign.center,
                      style: const TextStyle(
                        fontFamily: "Helvetica Neue Black Cond",
                        fontSize: 28.0,
                      ),
                    ),
                  ),
                  const SizedBox(
                    height: 8.0,
                  ),
                  Container(
                    padding: const EdgeInsets.symmetric(horizontal: 32.0),
                    width: double.infinity,
                    child: const Text(
                      "Por favor ingresa los datos requeridos para el cálculo del estacionamiento.",
                      textAlign: TextAlign.center,
                      style: TextStyle(
                        fontFamily: "Helvetica Neue Light",
                        fontSize: 22.0,
                        fontWeight: FontWeight.w600,
                        color: Color.fromRGBO(104, 104, 104, 1),
                      ),
                    ),
                  ),
                  const SizedBox(
                    height: 32.0,
                  ),
                  Container(
                    margin: const EdgeInsets.symmetric(
                      horizontal: 32.0,
                    ),
                    child: Row(
                      children: [
                        Text(
                          "Área:",
                          style: GoogleFonts.roboto(
                            fontWeight: FontWeight.bold,
                            fontSize: 18.0,
                          ),
                        ),
                        const SizedBox(width: 8.0),
                        Expanded(
                          child: SizedBox(
                            height: 64.0,
                            width: double.infinity,
                            child: Stack(
                              alignment: Alignment.center,
                              children: [
                                TextField(
                                  textAlign: TextAlign.center,
                                  controller: _areaController,
                                  maxLength: 10,
                                  decoration: const InputDecoration(
                                    counterText: "",
                                    counterStyle: TextStyle(
                                      height: double.minPositive,
                                    ),
                                  ),
                                  inputFormatters: [
                                    DecimalTextInputFormatter()
                                  ],
                                  onChanged: (val){
                                    _valArea = double.parse(val);
                                    _calcularVolumen();
                                  },
                                ),
                                Positioned(
                                  left: 0.0,
                                  child: IconButton(
                                    icon: const Icon(
                                      Icons.remove,
                                      color: Colors.black45,
                                    ),
                                    onPressed: () => setState(() {
                                      _valArea = _valArea - 0.1;

                                      if(_valArea < 0){
                                        _valArea = 0.0;
                                      }

                                      _areaController.text = _valArea.toStringAsFixed(2);
                                    }),
                                  ),
                                ),
                                Positioned(
                                  right: 0.0,
                                  child: IconButton(
                                    icon: const Icon(
                                      Icons.add,
                                      color: Colors.black45,
                                    ),
                                    onPressed: () => setState(() {
                                      _valArea = _valArea + 0.1;

                                      if(_valArea > 999){
                                        _valArea = 999.0;
                                      }

                                      _areaController.text = _valArea.toStringAsFixed(2);
                                    }),
                                  ),
                                ),
                              ],
                            ),
                          ),
                        ),
                        const SizedBox(width: 8.0),
                        DropdownButton<String>(
                          value: _unidadArea,
                          onChanged: (value) => setState((){
                            _unidadArea = value!;
                            _calcularVolumen();
                          }),
                          items: _unidadesArea.map((e) => DropdownMenuItem<String>(
                            child: Text(
                              e,
                              style: GoogleFonts.roboto(
                                  fontSize: 18.0
                              ),
                            ),
                            value: e,
                          )).toList(),
                        ),
                        const SizedBox(width: 8.0),
                        IconButton(
                          icon: const Icon(
                            Icons.info_outline,
                          ),
                          onPressed: () => showDialog(
                            context: context,
                            barrierDismissible: true,
                            builder: (context) => const AlertDialog(
                              title: Text(
                                "Área",
                              ),
                              content: Text(
                                "Es la superficie total a ventilar."
                              ),
                            ),
                          ),
                        )
                      ],
                    ),
                  ),
                  const SizedBox(
                    height: 16.0,
                  ),
                  Container(
                    margin: const EdgeInsets.symmetric(
                      horizontal: 32.0,
                    ),
                    child: Row(
                      children: [
                        Text(
                          "Altura:",
                          style: GoogleFonts.roboto(
                            fontWeight: FontWeight.bold,
                            fontSize: 18.0,
                          ),
                        ),
                        const SizedBox(width: 8.0),
                        Expanded(
                          child: SizedBox(
                            height: 64.0,
                            width: double.infinity,
                            child: Stack(
                              alignment: Alignment.center,
                              children: [
                                TextField(
                                  textAlign: TextAlign.center,
                                  controller: _alturaController,
                                  maxLength: 10,
                                  decoration: const InputDecoration(
                                    counterText: "",
                                    counterStyle: TextStyle(
                                      height: double.minPositive,
                                    ),
                                  ),
                                  inputFormatters: [
                                    DecimalTextInputFormatter()
                                  ],
                                  onChanged: (val){
                                    _valAltura = double.parse(val);
                                    _calcularVolumen();
                                  },
                                ),
                                Positioned(
                                  left: 0.0,
                                  child: IconButton(
                                    icon: const Icon(
                                      Icons.remove,
                                      color: Colors.black45,
                                    ),
                                    onPressed: () => setState(() {
                                      _valAltura = _valAltura - 0.1;

                                      if(_valAltura < 0){
                                        _valAltura = 0.0;
                                      }

                                      _alturaController.text = _valAltura.toStringAsFixed(2);
                                    }),
                                  ),
                                ),
                                Positioned(
                                  right: 0.0,
                                  child: IconButton(
                                    icon: const Icon(
                                      Icons.add,
                                      color: Colors.black45,
                                    ),
                                    onPressed: () => setState(() {
                                      _valAltura = _valAltura + 0.1;

                                      if(_valAltura > 999){
                                        _valAltura = 999.0;
                                      }

                                      _alturaController.text = _valAltura.toStringAsFixed(2);
                                    }),
                                  ),
                                ),
                              ],
                            ),
                          ),
                        ),
                        const SizedBox(width: 8.0),
                        DropdownButton<String>(
                          value: _unidadAltura,
                          onChanged: (value) => setState((){
                            _unidadAltura = value!;
                            _calcularVolumen();
                          }),
                          items: _unidadesAltura.map((e) => DropdownMenuItem<String>(
                            child: Text(
                              e,
                              style: GoogleFonts.roboto(
                                fontSize: 18.0,
                              ),
                            ),
                            value: e,
                          )).toList(),
                        ),
                        const SizedBox(width: 8.0),
                        IconButton(
                          icon: const Icon(
                            Icons.info_outline,
                          ),
                          onPressed: () => showDialog(
                            context: context,
                            barrierDismissible: true,
                            builder: (context) => const AlertDialog(
                              title: Text(
                                "Altura",
                              ),
                              content: Text(
                                "Es la altura libre neta.",
                              ),
                            ),
                          ),
                        )
                      ],
                    ),
                  ),
                  AnimatedCrossFade(
                    firstChild: Container(),
                    secondChild: Column(
                      children: [
                        const SizedBox(
                          height: 16.0,
                        ),
                        Row(
                          mainAxisAlignment: MainAxisAlignment.center,
                          crossAxisAlignment: CrossAxisAlignment.center,
                          children: [
                            RichText(
                              text: TextSpan(
                                children: [
                                  TextSpan(
                                    text: "Volúmen: ",
                                    style: GoogleFonts.roboto(
                                      fontWeight: FontWeight.bold,
                                    ),
                                  ),
                                  TextSpan(
                                    text: _valVolumen.toStringAsFixed(2),
                                  )
                                ],
                                style: GoogleFonts.roboto(
                                  fontSize: 18.0,
                                ),
                              ),
                              maxLines: 1,
                              overflow: TextOverflow.ellipsis,
                            ),
                            const SizedBox(
                              width: 8.0,
                            ),
                            DropdownButton<String>(
                              value: _unidadVolumen,
                              onChanged: (val) => setState((){
                                _unidadVolumen = val!;
                                _calcularVolumen();
                              }),
                              items: _unidadesVolumen.map((e) => DropdownMenuItem<String>(
                                child: Text(
                                  e,
                                  style: GoogleFonts.roboto(
                                    fontSize: 18.0,
                                  ),
                                ),
                                value: e,
                              )).toList(),
                            )
                          ],
                        ),
                        const SizedBox(
                          height: 4.0,
                        ),
                        Cubo(
                          width: containerWidth - 64.0,
                        ),
                        const SizedBox(
                          height: 16.0,
                        ),
                        Container(
                          margin: const EdgeInsets.symmetric(
                            horizontal: 32.0,
                          ),
                          child: Row(
                            children: [
                              Text(
                                "Normativa:",
                                style: GoogleFonts.roboto(
                                  fontWeight: FontWeight.bold,
                                  fontSize: 18.0,
                                ),
                              ),
                              const SizedBox(width: 8.0),
                              Expanded(
                                child: DropdownButton<int>(
                                  value: _normativa == 0 ? null : _normativa,
                                  isExpanded: true,
                                  hint: Text(
                                    "Selecciona una opción",
                                    style: GoogleFonts.roboto(
                                      color: Colors.grey,
                                      fontSize: 18.0,
                                      fontStyle: FontStyle.italic,
                                    ),
                                  ),
                                  onChanged: (newValue) => setState((){
                                    _normativa = newValue!;
                                    _calcularCaudal();
                                  }),
                                  items: _normativas.map((e) => DropdownMenuItem<int>(
                                    child: Text(
                                      e == 1 ? "ASHRAE 62.1-2010"
                                        : e == 2 ? "NFPA 88-A"
                                        : "Reglamento de construcción CDMX",
                                      style: GoogleFonts.roboto(
                                        fontSize: 18.0,
                                      ),
                                    ),
                                    value: e,
                                  )).toList(),
                                ),
                              )
                            ],
                          ),
                        ),
                        AnimatedCrossFade(
                          firstChild: Container(),
                          secondChild: Column(
                            children: [
                              const SizedBox(
                                height: 16.0,
                              ),
                              Container(
                                margin: const EdgeInsets.symmetric(
                                  horizontal: 32.0,
                                ),
                                child: Row(
                                  children: [
                                    Expanded(
                                      child: RichText(
                                        maxLines: 1,
                                        overflow: TextOverflow.ellipsis,
                                        textAlign: TextAlign.center,
                                        text: TextSpan(
                                          style: GoogleFonts.roboto(
                                            fontSize: 18.0,
                                          ),
                                          children: [
                                            TextSpan(
                                              text: "Caudal Extracción: ",
                                              style: GoogleFonts.roboto(
                                                fontWeight: FontWeight.bold,
                                              ),
                                            ),
                                            TextSpan(
                                              text: "${_caudalExtraccion.toStringAsFixed(2)} ${_normativa < 3 ? 'CFM' : 'm³/h'}",
                                            ),
                                          ],
                                        ),
                                      ),
                                    ),
                                    Expanded(
                                      child: RichText(
                                        maxLines: 1,
                                        overflow: TextOverflow.ellipsis,
                                        textAlign: TextAlign.center,
                                        text: TextSpan(
                                          style: GoogleFonts.roboto(
                                            fontSize: 18.0,
                                          ),
                                          children: [
                                            TextSpan(
                                              text: "Renovaciones por Segundo: ",
                                              style: GoogleFonts.roboto(
                                                fontWeight: FontWeight.bold,
                                              ),
                                            ),
                                            TextSpan(
                                              text: "${_renovaciones.toStringAsFixed(4)} ren/s",
                                            ),
                                          ],
                                        ),
                                      ),
                                    )
                                  ],
                                ),
                              ),
                              const SizedBox(
                                height: 16.0,
                              ),
                              Container(
                                margin: const EdgeInsets.symmetric(
                                  horizontal: 32.0,
                                ),
                                child: Row(
                                  children: [
                                    Text(
                                      "Distancia Máxima Recorrida:",
                                      style: GoogleFonts.roboto(
                                        fontWeight: FontWeight.bold,
                                        fontSize: 18.0,
                                      ),
                                    ),
                                    const SizedBox(width: 8.0),
                                    Expanded(
                                      child: SizedBox(
                                        height: 64.0,
                                        width: double.infinity,
                                        child: Stack(
                                          alignment: Alignment.center,
                                          children: [
                                            TextField(
                                              textAlign: TextAlign.center,
                                              controller: _distMaxController,
                                              maxLength: 10,
                                              decoration: const InputDecoration(
                                                counterText: "",
                                                counterStyle: TextStyle(
                                                  height: double.minPositive,
                                                ),
                                              ),
                                              inputFormatters: [
                                                DecimalTextInputFormatter()
                                              ],
                                              onChanged: (val){
                                                _valDistMax = double.parse(val);
                                                _calcularVelocidad();
                                              },
                                            ),
                                            Positioned(
                                              left: 0.0,
                                              child: IconButton(
                                                icon: const Icon(
                                                  Icons.remove,
                                                  color: Colors.black45,
                                                ),
                                                onPressed: () => setState(() {
                                                  _valDistMax = _valDistMax - 0.1;

                                                  if(_valDistMax < 0){
                                                    _valDistMax = 0.0;
                                                  }

                                                  _distMaxController.text = _valDistMax.toStringAsFixed(2);
                                                  _calcularVelocidad();
                                                }),
                                              ),
                                            ),
                                            Positioned(
                                              right: 0.0,
                                              child: IconButton(
                                                icon: const Icon(
                                                  Icons.add,
                                                  color: Colors.black45,
                                                ),
                                                onPressed: () => setState(() {
                                                  _valDistMax = _valDistMax + 0.1;

                                                  if(_valDistMax > 999){
                                                    _valDistMax = 999.0;
                                                  }

                                                  _distMaxController.text = _valDistMax.toStringAsFixed(2);
                                                  _calcularVelocidad();
                                                }),
                                              ),
                                            ),
                                          ],
                                        ),
                                      ),
                                    ),
                                    const SizedBox(width: 8.0),
                                    Container(
                                      child: Text(
                                        _unidadAltura,
                                        style: GoogleFonts.roboto(
                                          fontSize: 18.0,
                                        ),
                                      ),
                                      padding: const EdgeInsets.fromLTRB(0, 0, 24.0, 8.0),
                                      decoration: BoxDecoration(
                                        border: Border(
                                          bottom: BorderSide(
                                            color: Colors.black.withOpacity(0.18),
                                            width: 2.0,
                                          ),
                                        ),
                                      ),
                                    ),
                                    const SizedBox(width: 8.0),
                                    IconButton(
                                      icon: const Icon(
                                        Icons.info_outline,
                                      ),
                                      onPressed: () => showDialog(
                                        context: context,
                                        barrierDismissible: true,
                                        builder: (context) => const AlertDialog(
                                          title: Text(
                                            "Distancia Máxima Recorrida",
                                          ),
                                          content: Text(
                                            "Distancia máxima recorrida por un auto desde que ingresa hasta que localiza un lugar para estacionarse.",
                                          ),
                                        ),
                                      ),
                                    )
                                  ],
                                ),
                              ),
                              AnimatedCrossFade(
                                firstChild: Container(),
                                secondChild: Column(
                                  children: [
                                    const SizedBox(
                                      height: 16.0,
                                    ),
                                    Container(
                                      margin: const EdgeInsets.symmetric(
                                        horizontal: 32.0,
                                      ),
                                      child: Row(
                                        children: [
                                          Expanded(
                                            child: RichText(
                                              maxLines: 1,
                                              overflow: TextOverflow.ellipsis,
                                              textAlign: TextAlign.center,
                                              text: TextSpan(
                                                style: GoogleFonts.roboto(
                                                  fontSize: 18.0,
                                                ),
                                                children: [
                                                  TextSpan(
                                                    text: "Velocidad Inducida: ",
                                                    style: GoogleFonts.roboto(
                                                      fontWeight: FontWeight.bold,
                                                    ),
                                                  ),
                                                  TextSpan(
                                                    text: "${_valVelInducida.toStringAsFixed(2)} m/s",
                                                  ),
                                                ],
                                              ),
                                            ),
                                          ),
                                          Expanded(
                                            child: RichText(
                                              maxLines: 1,
                                              overflow: TextOverflow.ellipsis,
                                              textAlign: TextAlign.center,
                                              text: TextSpan(
                                                style: GoogleFonts.roboto(
                                                  fontSize: 18.0,
                                                ),
                                                children: [
                                                  TextSpan(
                                                    text: "Velocidad Mínima Recomendada: ",
                                                    style: GoogleFonts.roboto(
                                                      fontWeight: FontWeight.bold,
                                                    ),
                                                  ),
                                                  const TextSpan(
                                                    text: "0.25 m/s",
                                                  ),
                                                ],
                                              ),
                                            ),
                                          )
                                        ],
                                      ),
                                    ),
                                    const SizedBox(
                                      height: 16.0,
                                    ),
                                    Container(
                                      margin: const EdgeInsets.symmetric(
                                        horizontal: 32.0,
                                      ),
                                      child: Row(
                                        children: [
                                          Text(
                                            "Ubicación:",
                                            style: GoogleFonts.roboto(
                                              fontWeight: FontWeight.bold,
                                              fontSize: 18.0,
                                            ),
                                          ),
                                          const SizedBox(width: 8.0),
                                          Expanded(
                                            child: DropdownButton<String>(
                                              value: _ubicacion,
                                              isExpanded: true,
                                              onChanged: (newValue) async{
                                                setState(() => _consultando = true);
                                                _ubicacion = newValue!;

                                                var uri;
                                                if(newValue.contains("(Ubicación actual)")){
                                                  final latLon = newValue.replaceAll("(Ubicación actual)", "");
                                                  final arr = latLon.split(",");

                                                  final lat = arr[0].trim();
                                                  final lon = arr[1].trim();
                                                  
                                                  uri = Uri.parse("https://api.openweathermap.org/data/2.5/weather?lat=$lat&lon=$lon&appid=fe3b68585dbadc9da643f5f720edba85&units=metric");
                                                }else{
                                                  final ciudad = newValue.replaceAll("(Ubicación de la cuenta)", "");
                                                  final arr = ciudad.split(",");

                                                  final city = arr[0].trim();
                                                  final est = arr[1].trim().split(" ").last.replaceAll("(", "").replaceAll(")", "");
                                                  final pais = widget.pais.split(" ").last.replaceAll("(", "").replaceAll(")", "");

                                                  uri = Uri.parse("https://api.openweathermap.org/data/2.5/weather?q=$city,$est,$pais&appid=fe3b68585dbadc9da643f5f720edba85&units=metric");
                                                }

                                                final res = await http.get(uri);
                                                final dec = jsonDecode(res.body);

                                                _tempCiudad = dec["main"]["temp"];

                                                final url = Uri.https("www.solerpalau.mx", "mdc.qa/altitud.php");
                                                final resp = await http.post(url,
                                                  body: {
                                                    "LAT" : "${dec["coord"]["lat"]}",
                                                    "LON" : "${dec["coord"]["lon"]}",
                                                  },
                                                );

                                                final decoded = jsonDecode(resp.body);
                                                _alturaCiudad = decoded["results"][0]["elevation"];
                                                _densidad = (1 / ((0.9318 + (0.00341 * _tempCiudad)) * math.exp(0.0001186 * _alturaCiudad))) * 1.2;

                                                setState(() => _consultando = false);
                                              },
                                              items: _ubicaciones.map((e) => DropdownMenuItem<String>(
                                                child: Text(
                                                  e,
                                                  style: GoogleFonts.roboto(
                                                    fontSize: 18.0,
                                                  ),
                                                ),
                                                value: e,
                                              )).toList(),
                                            ),
                                          )
                                        ],
                                      ),
                                    ),
                                    const SizedBox(
                                      height: 16.0,
                                    ),
                                    Container(
                                      margin: const EdgeInsets.symmetric(
                                        horizontal: 32.0,
                                      ),
                                      child: _consultando ? const Center(
                                        child: CircularProgressIndicator(),
                                      ) : Row(
                                        children: [
                                          Expanded(
                                            child: RichText(
                                              maxLines: 1,
                                              overflow: TextOverflow.ellipsis,
                                              textAlign: TextAlign.center,
                                              text: TextSpan(
                                                style: GoogleFonts.roboto(
                                                  fontSize: 18.0,
                                                ),
                                                children: [
                                                  TextSpan(
                                                    text: "Altura: ",
                                                    style: GoogleFonts.roboto(
                                                      fontWeight: FontWeight.bold,
                                                    ),
                                                  ),
                                                  TextSpan(
                                                    text: "${_alturaCiudad.toStringAsFixed(2)} m",
                                                  ),
                                                ],
                                              ),
                                            ),
                                          ),
                                          Expanded(
                                            child: RichText(
                                              maxLines: 1,
                                              overflow: TextOverflow.ellipsis,
                                              textAlign: TextAlign.center,
                                              text: TextSpan(
                                                style: GoogleFonts.roboto(
                                                  fontSize: 18.0,
                                                ),
                                                children: [
                                                  TextSpan(
                                                    text: "Temperatura: ",
                                                    style: GoogleFonts.roboto(
                                                      fontWeight: FontWeight.bold,
                                                    ),
                                                  ),
                                                  TextSpan(
                                                    text: "$_tempCiudad °C",
                                                  ),
                                                ],
                                              ),
                                            ),
                                          ),
                                          Expanded(
                                            child: RichText(
                                              maxLines: 1,
                                              overflow: TextOverflow.ellipsis,
                                              textAlign: TextAlign.center,
                                              text: TextSpan(
                                                style: GoogleFonts.roboto(
                                                  fontSize: 18.0,
                                                ),
                                                children: [
                                                  TextSpan(
                                                    text: "Densidad: ",
                                                    style: GoogleFonts.roboto(
                                                      fontWeight: FontWeight.bold,
                                                    ),
                                                  ),
                                                  TextSpan(
                                                    text: _densidad.toStringAsFixed(2),
                                                  ),
                                                ],
                                              ),
                                            ),
                                          ),
                                        ],
                                      ),
                                    ),
                                    const SizedBox(
                                      height: 16.0,
                                    ),
                                    Container(
                                      margin: const EdgeInsets.symmetric(
                                        horizontal: 32.0,
                                      ),
                                      child: Row(
                                        children: [
                                          Text(
                                            "Equipo:",
                                            style: GoogleFonts.roboto(
                                              fontWeight: FontWeight.bold,
                                              fontSize: 18.0,
                                            ),
                                          ),
                                          const SizedBox(width: 8.0),
                                          Expanded(
                                            child: DropdownButton<String>(
                                              value: _equipo,
                                              isExpanded: true,
                                              onChanged: (newValue) => setState((){
                                                _equipo = newValue!;
                                              }),
                                              items: _equipos.map((e) => DropdownMenuItem<String>(
                                                child: Text(
                                                  e,
                                                  style: GoogleFonts.roboto(
                                                    fontSize: 18.0,
                                                  ),
                                                ),
                                                value: e,
                                              )).toList(),
                                            ),
                                          ),
                                        ],
                                      ),
                                    ),
                                    const SizedBox(
                                      height: 16.0,
                                    ),
                                    Container(
                                      margin: const EdgeInsets.symmetric(
                                        horizontal: 32.0,
                                      ),
                                      child: Row(
                                        children: [
                                          Text(
                                            "Modelo:",
                                            style: GoogleFonts.roboto(
                                              fontWeight: FontWeight.bold,
                                              fontSize: 18.0,
                                            ),
                                          ),
                                          const SizedBox(width: 8.0),
                                          Expanded(
                                            child: DropdownButton<String>(
                                              value: _modelo.isEmpty ? null : _modelo,
                                              hint: Text(
                                                "Selecciona una opción",
                                                style: GoogleFonts.roboto(
                                                  color: Colors.grey,
                                                  fontSize: 18.0,
                                                  fontStyle: FontStyle.italic,
                                                ),
                                              ),
                                              isExpanded: true,
                                              onChanged: (newValue) => setState((){
                                                _modelo = newValue!;
                                                _calcularSuperficieVentilada();
                                              }),
                                              items: _listaEquipos[_equipo]!.keys.map((e) => DropdownMenuItem<String>(
                                                child: Text(
                                                  e,
                                                  style: GoogleFonts.roboto(
                                                    fontSize: 18.0,
                                                  ),
                                                ),
                                                value: e,
                                              )).toList(),
                                            ),
                                          ),
                                        ],
                                      ),
                                    ),
                                    AnimatedCrossFade(
                                      firstChild: Container(),
                                      secondChild: Column(
                                        children: [
                                          const SizedBox(
                                            height: 16.0,
                                          ),
                                          Container(
                                            margin: const EdgeInsets.symmetric(
                                              horizontal: 32.0,
                                            ),
                                            child: Row(
                                              children: [
                                                Expanded(
                                                  child: RichText(
                                                    maxLines: 1,
                                                    overflow: TextOverflow.ellipsis,
                                                    textAlign: TextAlign.center,
                                                    text: TextSpan(
                                                      style: GoogleFonts.roboto(
                                                        fontSize: 18.0,
                                                      ),
                                                      children: [
                                                        TextSpan(
                                                          text: "Empuje(N): ",
                                                          style: GoogleFonts.roboto(
                                                            fontWeight: FontWeight.bold,
                                                          ),
                                                        ),
                                                        TextSpan(
                                                          text: "${_listaEquipos[_equipo]![_modelo]}",
                                                        ),
                                                      ],
                                                    ),
                                                  ),
                                                ),
                                                Expanded(
                                                  child: RichText(
                                                    maxLines: 1,
                                                    overflow: TextOverflow.ellipsis,
                                                    textAlign: TextAlign.center,
                                                    text: TextSpan(
                                                      style: GoogleFonts.roboto(
                                                        fontSize: 18.0,
                                                      ),
                                                      children: [
                                                        TextSpan(
                                                          text: "Constante (k): ",
                                                          style: GoogleFonts.roboto(
                                                            fontWeight: FontWeight.bold,
                                                          ),
                                                        ),
                                                        const TextSpan(
                                                          text: "0.54",
                                                        ),
                                                      ],
                                                    ),
                                                  ),
                                                ),
                                                Expanded(
                                                  child: RichText(
                                                    maxLines: 1,
                                                    overflow: TextOverflow.ellipsis,
                                                    textAlign: TextAlign.center,
                                                    text: TextSpan(
                                                      style: GoogleFonts.roboto(
                                                        fontSize: 18.0,
                                                      ),
                                                      children: [
                                                        TextSpan(
                                                          text: "V²: ",
                                                          style: GoogleFonts.roboto(
                                                            fontWeight: FontWeight.bold,
                                                          ),
                                                        ),
                                                        TextSpan(
                                                          text: "${math.pow(_valVelInducida < 0.25 ? 0.25 : _valVelInducida, 2).toStringAsFixed(3)} m²/s²",
                                                        ),
                                                      ],
                                                    ),
                                                  ),
                                                ),
                                              ],
                                            ),
                                          ),
                                          const SizedBox(
                                            height: 16.0,
                                          ),
                                          Container(
                                            margin: const EdgeInsets.symmetric(
                                              horizontal: 32.0,
                                            ),
                                            child: Row(
                                              children: [
                                                Expanded(
                                                  child: RichText(
                                                    maxLines: 1,
                                                    overflow: TextOverflow.ellipsis,
                                                    textAlign: TextAlign.center,
                                                    text: TextSpan(
                                                      style: GoogleFonts.roboto(
                                                        fontSize: 18.0,
                                                      ),
                                                      children: [
                                                        TextSpan(
                                                          text: "Superficie Ventilada: ",
                                                          style: GoogleFonts.roboto(
                                                            fontWeight: FontWeight.bold,
                                                          ),
                                                        ),
                                                        TextSpan(
                                                          text: "${_superficieVentilada.toStringAsFixed(2)} m²",
                                                        ),
                                                      ],
                                                    ),
                                                  ),
                                                ),
                                                Expanded(
                                                  child: RichText(
                                                    maxLines: 1,
                                                    overflow: TextOverflow.ellipsis,
                                                    textAlign: TextAlign.center,
                                                    text: TextSpan(
                                                      style: GoogleFonts.roboto(
                                                        fontSize: 18.0,
                                                      ),
                                                      children: [
                                                        TextSpan(
                                                          text: "Equipos: ",
                                                          style: GoogleFonts.roboto(
                                                            fontWeight: FontWeight.bold,
                                                          ),
                                                        ),
                                                        TextSpan(
                                                          text: _cantEquipos.toStringAsFixed(2),
                                                        ),
                                                      ],
                                                    ),
                                                  ),
                                                ),
                                              ],
                                            ),
                                          ),
                                          const SizedBox(
                                            height: 16.0,
                                          ),
                                          Container(
                                            margin: const EdgeInsets.symmetric(
                                              horizontal: 32.0,
                                            ),
                                            child: Text(
                                              "Cantidad de Equipos TOTAL: $_intEquipos EQUIPO(S)",
                                              textAlign: TextAlign.center,
                                              style: GoogleFonts.roboto(
                                                fontSize: 18.0,
                                                fontWeight: FontWeight.bold,
                                              ),
                                            ),
                                          ),
                                        ],
                                      ),
                                      duration: const Duration(milliseconds: 250),
                                      crossFadeState: _superficieVentilada == 0 ? CrossFadeState.showFirst : CrossFadeState.showSecond,
                                    )
                                  ],
                                ),
                                duration: const Duration(milliseconds: 250),
                                crossFadeState: _valDistMax == 0 ? CrossFadeState.showFirst : CrossFadeState.showSecond,
                              )
                            ],
                          ),
                          duration: const Duration(milliseconds: 250),
                          crossFadeState: _caudalExtraccion == 0 ? CrossFadeState.showFirst : CrossFadeState.showSecond,
                        )
                      ],
                    ),
                    duration: const Duration(
                      milliseconds: 250,
                    ),
                    crossFadeState: _valVolumen == 0 ? CrossFadeState.showFirst : CrossFadeState.showSecond,
                  ),
                  const SizedBox(
                    height: 32.0,
                  ),
                  Container(
                    margin: const EdgeInsets.symmetric(
                      horizontal: 32.0,
                    ),
                    child: Row(
                      children: [
                        Expanded(
                          child: MaterialButton(
                            elevation: 4,
                            padding: const EdgeInsets.symmetric(vertical: 16.0),
                            minWidth: (containerWidth/2)-32,
                            color: const Color(0xFFFF0000),
                            child: Row(
                              mainAxisAlignment: MainAxisAlignment.center,
                              children: [
                                Image.asset(
                                  "guardar.png",
                                  width: 32.0,
                                ),
                                const SizedBox(width: 8.0),
                                const Text(
                                  "Guardar y regresar",
                                  style: TextStyle(
                                    fontFamily: "Helvetica Neue Black Cond",
                                    color: Colors.white,
                                    fontSize: 28.0,
                                  ),
                                )
                              ],
                            ),
                            onPressed: () async{
                            },
                          ),
                        ),
                        const SizedBox(width: 16.0),
                        Expanded(
                          child: MaterialButton(
                            elevation: 4,
                            padding: const EdgeInsets.symmetric(vertical: 16.0),
                            minWidth: (containerWidth/2)-32,
                            color: const Color(0xFFFF0000),
                            disabledColor: Colors.grey,
                            child: Row(
                              mainAxisAlignment: MainAxisAlignment.center,
                              children: [
                                Image.asset(
                                  "continuar.png",
                                  width: 32.0,
                                ),
                                const SizedBox(width: 8.0),
                                const Text(
                                  "Continuar",
                                  style: TextStyle(
                                    fontFamily: "Helvetica Neue Black Cond",
                                    color: Colors.white,
                                    fontSize: 28.0,
                                  ),
                                )
                              ],
                            ),
                            onPressed: () => true,
                          ),
                        )
                      ],
                    ),
                  ),
                  const SizedBox(
                    height: 32.0,
                  ),
                ],
              ),
            ),
          );
        },
      ),
    );
  }

  void _calcularVolumen() => setState(() {
    if(_valAltura != 0 && _valArea != 0){
      if(_unidadVolumen == "m³"){
        if(_unidadArea == "m²" && _unidadAltura == "m"){
          _valVolumen = _valAltura * _valArea;
        }else if(_unidadArea == "ft²" && _unidadAltura == "m"){
          double conversion = _valArea / 10.764;
          _valVolumen = _valAltura * conversion;
        }else if(_unidadArea == "m²" && _unidadAltura == "ft"){
          double conversion = _valAltura / 3.281;
          _valVolumen = _valArea * conversion;
        }else{
          double conversion1 = _valArea / 10.764;
          double conversion2 = _valAltura / 3.281;
          _valVolumen = conversion1 * conversion2;
        }
      }else{
        if(_unidadArea == "m²" && _unidadAltura == "m"){
          double conversion1 = _valArea * 10.764;
          double conversion2 = _valAltura * 3.281;
          _valVolumen = conversion1 * conversion2;
        }else if(_unidadArea == "ft²" && _unidadAltura == "m"){
          double conversion = _valAltura * 3.281;
          _valVolumen = _valAltura * conversion;
        }else if(_unidadArea == "m²" && _unidadAltura == "ft"){
          double conversion = _valArea * 10.764;
          _valVolumen = _valArea * conversion;
        }else{
          _valVolumen = _valAltura * _valArea;
        }
      }

      if(_normativa > 0) _calcularCaudal();
    }
  });

  void _calcularCaudal () => setState(() {
    switch(_normativa){
      case 1:
        double area = _unidadArea == "m²" ? _valArea * 10.76 : _valArea;
        _caudalExtraccion = area * 0.75;

        double volumen = _unidadVolumen == "ft³" ? _valVolumen / 35.3147 : _valVolumen;
        _renovaciones = (_caudalExtraccion * 0.00047) / volumen;
        break;
      case 2:
        double area = _unidadArea == "m²" ? _valArea * 10.76 : _valArea;
        _caudalExtraccion = area;

        double volumen = _unidadVolumen == "ft³" ? _valVolumen / 35.3147 : _valVolumen;
        _renovaciones = (_caudalExtraccion * 0.00047) / volumen;
        break;
      case 3:
        double volumen = _unidadVolumen == "ft³" ? _valVolumen / 35.3147 : _valVolumen;
        _caudalExtraccion = volumen * 10;
        _renovaciones = 10 / 3600;
        break;
    }
  });

  void _calcularVelocidad() => setState(() {
    if(_valDistMax > 0){
      _valVelInducida = _valDistMax * _renovaciones;
    }
  });

  void _calcularSuperficieVentilada() => setState(() {
    final empuje = _listaEquipos[_equipo]![_modelo];
    const k = 0.54;
    final velInd = math.pow(_valVelInducida < 0.25 ? 0.25 : _valVelInducida, 2);

    _superficieVentilada = empuje! / (k * _densidad * velInd);
    _cantEquipos = _valArea / _superficieVentilada;

    int equiposInt = _cantEquipos.toInt();
    double fraccion = _cantEquipos - equiposInt;

    _intEquipos = fraccion > 0.0 ? equiposInt + 1 : equiposInt;
  });
}
