calculadora.dart 61 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516
  1. import 'package:flutter/material.dart';
  2. import 'package:fluttertoast/fluttertoast.dart';
  3. import 'package:google_fonts/google_fonts.dart';
  4. import '../pages/resultado.dart';
  5. import '../models/info_calculadora.dart';
  6. import '../providers/info_calculadora_provider.dart';
  7. import 'dart:math' as math;
  8. class CalculadoraPage extends StatefulWidget {
  9. const CalculadoraPage({Key? key}) : super(key: key);
  10. @override
  11. State<CalculadoraPage> createState() => _CalculadoraPageState();
  12. }
  13. class _CalculadoraPageState extends State<CalculadoraPage> {
  14. final _infoCalculadoraProvider = InfoCalculadoraProvider();
  15. final _caudalController = TextEditingController();
  16. final _presionController = TextEditingController();
  17. final _potenciaController = TextEditingController();
  18. final _diametroController = TextEditingController();
  19. late String _tipoVentilador;
  20. late String _modeloVentilador;
  21. late String _caudal;
  22. late String _presionEstatica;
  23. late String _potenciaAbsorbida;
  24. late String _diametroVentilador;
  25. late String _curvaNC;
  26. bool _isLoading = true;
  27. late List<Atenuacion> _atenuacion;
  28. late List<PotenciaSonora> _potenciaSonora;
  29. final List<String> _caudalUnidades = [
  30. 'M3/S','M3/MIN','M3/H','L/S','L/MIN','L/H','CM3/S','CM3/MIN','CM3/H',
  31. 'GALON/S','GALON/MIN','GALON/H','CFM'
  32. ];
  33. final List<String> _presionUnidades = [
  34. 'MPA','KPA','PA','BAR','M CA','CM A','MM CA','IN HG','CM HG','MM HG',
  35. 'TORR','INWG'
  36. ];
  37. final List<String> _potenciaUnidades = [
  38. 'HP','J/S','KCAL/H','KW','WATT','PIE-LIBRA(S)','PIE-LIBRA(M)','BHP'
  39. ];
  40. final List<String> _diametroUnidades = [
  41. 'MM','CM','DM','M','MI','YARDA','INCH','FT'
  42. ];
  43. final List<String> _curvas = [
  44. 'NC15','NC20','NC25','NC30','NC35','NC40','NC45','NC50','NC55','NC60',
  45. 'NC65','NC70'
  46. ];
  47. late List<String> _ventiladoresTipos;
  48. late List<Ventilador> _ventiladores;
  49. final Map<String, List<String>> _ventiladoresModelos = {
  50. 'Seleccione un tipo de ventilador...' : ['']
  51. };
  52. @override
  53. void initState() {
  54. super.initState();
  55. _infoCalculadoraProvider.fetchInfoCalculadora().then((infoCalculadora){
  56. _ventiladoresTipos = [];
  57. _ventiladoresTipos.add('Seleccione un tipo de ventilador...');
  58. _ventiladores = infoCalculadora.result!.ventiladores!;
  59. if(infoCalculadora.result!.ventiladoresTipos!.isNotEmpty){
  60. int i = 0;
  61. do{
  62. _ventiladoresTipos.add(infoCalculadora.result!.ventiladoresTipos![i]);
  63. i++;
  64. }while(i < infoCalculadora.result!.ventiladoresTipos!.length);
  65. }else{
  66. _errorCarga('Hubo un error al cargar el Catálogo de ventiladores');
  67. }
  68. if(infoCalculadora.result!.ventiladoresModelos!.isNotEmpty){
  69. int i = 0;
  70. do{
  71. _ventiladoresModelos[infoCalculadora.result!.ventiladoresTipos![i]] = infoCalculadora.result!.ventiladoresModelos![i];
  72. i++;
  73. }while(i < infoCalculadora.result!.ventiladoresModelos!.length);
  74. }else{
  75. _errorCarga('Hubo un error al cargar los Modelos de ventiladores');
  76. }
  77. _atenuacion = infoCalculadora.result!.atenuacion!;
  78. _potenciaSonora = infoCalculadora.result!.potenciaSonora!;
  79. _initVariables();
  80. });
  81. }
  82. void _initVariables(){
  83. setState(() {
  84. _tipoVentilador = _ventiladoresTipos[0];
  85. _modeloVentilador = _ventiladoresModelos[_tipoVentilador]![0];
  86. _caudal = _caudalUnidades.last;
  87. _presionEstatica = _presionUnidades.last;
  88. _potenciaAbsorbida = _potenciaUnidades.last;
  89. _diametroVentilador = _diametroUnidades.last;
  90. _curvaNC = _curvas[0];
  91. _isLoading = false;
  92. });
  93. }
  94. @override
  95. Widget build(BuildContext context) {
  96. final _screenSize = MediaQuery.of(context).size;
  97. return Scaffold(
  98. appBar: AppBar(),
  99. body: _isLoading ? const Center(
  100. child: CircularProgressIndicator(),
  101. ) : SafeArea(
  102. child: SingleChildScrollView(
  103. child: Column(
  104. children: <Widget>[
  105. Container(
  106. margin: const EdgeInsets.symmetric(vertical: 16.0, horizontal: 32.0),
  107. width: _screenSize.width,
  108. child: Text(
  109. 'Tipo de Ventilador *',
  110. textAlign: TextAlign.start,
  111. style: GoogleFonts.roboto(
  112. color: const Color(0xFF333333),
  113. fontWeight: FontWeight.w700,
  114. fontSize: 20.0
  115. ),
  116. ),
  117. ),
  118. Container(
  119. decoration: BoxDecoration(
  120. border: Border.all(
  121. color: const Color(0xFFBBBBBB)
  122. ),
  123. borderRadius: BorderRadius.circular(8.0)
  124. ),
  125. padding: const EdgeInsets.symmetric(horizontal: 16),
  126. child: DropdownButton<String>(
  127. value: _tipoVentilador,
  128. elevation: 16,
  129. underline: Container(
  130. height: 0,
  131. color: const Color(0x00000000),
  132. ),
  133. onChanged: (value){
  134. setState(() {
  135. _tipoVentilador = value!;
  136. _modeloVentilador = _ventiladoresModelos[value]![0];
  137. });
  138. },
  139. items: _ventiladoresTipos.map<DropdownMenuItem<String>>((value){
  140. return DropdownMenuItem<String>(
  141. value: value,
  142. child: SizedBox(
  143. width: _screenSize.width-122.0,
  144. child: Text(
  145. value,
  146. textAlign: TextAlign.start,
  147. style: GoogleFonts.roboto(
  148. color: Colors.black
  149. ),
  150. ),
  151. ),
  152. );
  153. }).toList(),
  154. ),
  155. ),
  156. Container(
  157. margin: const EdgeInsets.symmetric(vertical: 16.0, horizontal: 32.0),
  158. width: _screenSize.width,
  159. child: Text(
  160. 'Modelo de Ventilador *',
  161. style: GoogleFonts.roboto(
  162. color: const Color(0xFF333333),
  163. fontWeight: FontWeight.w700,
  164. fontSize: 20.0
  165. ),
  166. ),
  167. ),
  168. Container(
  169. decoration: BoxDecoration(
  170. border: Border.all(
  171. color: const Color(0xFFBBBBBB)
  172. ),
  173. borderRadius: BorderRadius.circular(8.0)
  174. ),
  175. padding: const EdgeInsets.symmetric(horizontal: 16),
  176. child: DropdownButton<String>(
  177. value: _modeloVentilador,
  178. underline: Container(
  179. height: 0,
  180. color: const Color(0x00000000),
  181. ),
  182. elevation: 16,
  183. onChanged: (value){
  184. setState(() {
  185. _modeloVentilador = value!;
  186. });
  187. },
  188. items: _ventiladoresModelos[_tipoVentilador]!.map<DropdownMenuItem<String>>((value){
  189. return DropdownMenuItem<String>(
  190. value: value,
  191. child: SizedBox(
  192. width: _screenSize.width-122.0,
  193. child: Text(
  194. value,
  195. textAlign: TextAlign.start,
  196. style: GoogleFonts.roboto(
  197. color: Colors.black
  198. ),
  199. ),
  200. ),
  201. );
  202. }).toList(),
  203. ),
  204. ),
  205. Container(
  206. margin: const EdgeInsets.symmetric(vertical: 16.0, horizontal: 32.0),
  207. width: _screenSize.width,
  208. child: Text(
  209. 'Caudal (Q) *',
  210. style: GoogleFonts.roboto(
  211. color: const Color(0xFF333333),
  212. fontWeight: FontWeight.w700,
  213. fontSize: 20.0
  214. ),
  215. ),
  216. ),
  217. Row(
  218. children: [
  219. const SizedBox(width: 32.0),
  220. Expanded(
  221. child: Container(
  222. decoration: BoxDecoration(
  223. border: Border.all(
  224. color: const Color(0xFFBBBBBB)
  225. ),
  226. borderRadius: BorderRadius.circular(8.0)
  227. ),
  228. padding: const EdgeInsets.symmetric(horizontal: 16),
  229. child: TextField(
  230. controller: _caudalController,
  231. keyboardType: TextInputType.number,
  232. decoration: const InputDecoration(
  233. border: InputBorder.none,
  234. ),
  235. ),
  236. ),
  237. ),
  238. const SizedBox(width: 16.0),
  239. Container(
  240. decoration: BoxDecoration(
  241. border: Border.all(
  242. color: const Color(0xFFBBBBBB)
  243. ),
  244. borderRadius: BorderRadius.circular(8.0)
  245. ),
  246. padding: const EdgeInsets.symmetric(horizontal: 16),
  247. child: DropdownButton<String>(
  248. value: _caudal,
  249. elevation: 16,
  250. style: GoogleFonts.roboto(
  251. color: Colors.black
  252. ),
  253. underline: Container(
  254. height: 0,
  255. color: const Color(0x00000000),
  256. ),
  257. onChanged: (value){
  258. setState(() {
  259. _caudal = value!;
  260. });
  261. },
  262. items: _caudalUnidades.map<DropdownMenuItem<String>>((value){
  263. return DropdownMenuItem<String>(
  264. value: value,
  265. child: Text(
  266. value
  267. ),
  268. );
  269. }).toList(),
  270. ),
  271. ),
  272. const SizedBox(width: 32.0)
  273. ],
  274. ),
  275. Container(
  276. margin: const EdgeInsets.symmetric(vertical: 16.0, horizontal: 32.0),
  277. width: _screenSize.width,
  278. child: Text(
  279. 'Presión Estática (P) *',
  280. style: GoogleFonts.roboto(
  281. color: const Color(0xFF333333),
  282. fontWeight: FontWeight.w700,
  283. fontSize: 20.0
  284. ),
  285. ),
  286. ),
  287. Row(
  288. children: [
  289. const SizedBox(width: 32.0),
  290. Expanded(
  291. child: Container(
  292. decoration: BoxDecoration(
  293. border: Border.all(
  294. color: const Color(0xFFBBBBBB)
  295. ),
  296. borderRadius: BorderRadius.circular(8.0)
  297. ),
  298. padding: const EdgeInsets.symmetric(horizontal: 16),
  299. child: TextField(
  300. controller: _presionController,
  301. keyboardType: TextInputType.number,
  302. decoration: InputDecoration(
  303. border: InputBorder.none,
  304. ),
  305. ),
  306. ),
  307. ),
  308. SizedBox(width: 16.0),
  309. Container(
  310. decoration: BoxDecoration(
  311. border: Border.all(
  312. color: Color(0xFFBBBBBB)
  313. ),
  314. borderRadius: BorderRadius.circular(8.0)
  315. ),
  316. padding: EdgeInsets.symmetric(horizontal: 16),
  317. child: DropdownButton<String>(
  318. value: _presionEstatica,
  319. elevation: 16,
  320. style: GoogleFonts.roboto(
  321. color: Colors.black
  322. ),
  323. underline: Container(
  324. height: 0,
  325. color: Color(0x00000000),
  326. ),
  327. onChanged: (value){
  328. setState(() {
  329. _presionEstatica = value!;
  330. });
  331. },
  332. items: _presionUnidades.map<DropdownMenuItem<String>>((value){
  333. return DropdownMenuItem<String>(
  334. value: value,
  335. child: Text(
  336. value
  337. ),
  338. );
  339. }).toList(),
  340. ),
  341. ),
  342. SizedBox(width: 32.0)
  343. ],
  344. ),
  345. Container(
  346. margin: EdgeInsets.symmetric(vertical: 16.0, horizontal: 32.0),
  347. width: _screenSize.width,
  348. child: Text(
  349. 'Potencia Absorbida (Bhp) *',
  350. style: GoogleFonts.roboto(
  351. color: Color(0xFF333333),
  352. fontWeight: FontWeight.w700,
  353. fontSize: 20.0
  354. ),
  355. ),
  356. ),
  357. Row(
  358. children: [
  359. SizedBox(width: 32.0),
  360. Expanded(
  361. child: Container(
  362. decoration: BoxDecoration(
  363. border: Border.all(
  364. color: Color(0xFFBBBBBB)
  365. ),
  366. borderRadius: BorderRadius.circular(8.0)
  367. ),
  368. padding: EdgeInsets.symmetric(horizontal: 16),
  369. child: TextField(
  370. controller: _potenciaController,
  371. keyboardType: TextInputType.number,
  372. decoration: InputDecoration(
  373. border: InputBorder.none,
  374. ),
  375. ),
  376. ),
  377. ),
  378. SizedBox(width: 16.0),
  379. Container(
  380. decoration: BoxDecoration(
  381. border: Border.all(
  382. color: Color(0xFFBBBBBB)
  383. ),
  384. borderRadius: BorderRadius.circular(8.0)
  385. ),
  386. padding: EdgeInsets.symmetric(horizontal: 16),
  387. child: DropdownButton<String>(
  388. value: _potenciaAbsorbida,
  389. elevation: 16,
  390. style: GoogleFonts.roboto(
  391. color: Colors.black
  392. ),
  393. underline: Container(
  394. height: 0,
  395. color: Color(0x00000000),
  396. ),
  397. onChanged: (value){
  398. setState(() {
  399. _potenciaAbsorbida = value!;
  400. });
  401. },
  402. items: _potenciaUnidades.map<DropdownMenuItem<String>>((value){
  403. return DropdownMenuItem<String>(
  404. value: value,
  405. child: Text(
  406. value
  407. ),
  408. );
  409. }).toList(),
  410. ),
  411. ),
  412. SizedBox(width: 32.0)
  413. ],
  414. ),
  415. Container(
  416. margin: EdgeInsets.symmetric(vertical: 16.0, horizontal: 32.0),
  417. width: _screenSize.width,
  418. child: Text(
  419. 'Diámetro del Ventilador *',
  420. style: GoogleFonts.roboto(
  421. color: Color(0xFF333333),
  422. fontWeight: FontWeight.w700,
  423. fontSize: 20.0
  424. ),
  425. ),
  426. ),
  427. Row(
  428. children: [
  429. SizedBox(width: 32.0),
  430. Expanded(
  431. child: Container(
  432. decoration: BoxDecoration(
  433. border: Border.all(
  434. color: Color(0xFFBBBBBB)
  435. ),
  436. borderRadius: BorderRadius.circular(8.0)
  437. ),
  438. padding: EdgeInsets.symmetric(horizontal: 16),
  439. child: TextField(
  440. controller: _diametroController,
  441. keyboardType: TextInputType.number,
  442. decoration: InputDecoration(
  443. border: InputBorder.none,
  444. ),
  445. ),
  446. ),
  447. ),
  448. SizedBox(width: 16.0),
  449. Container(
  450. decoration: BoxDecoration(
  451. border: Border.all(
  452. color: Color(0xFFBBBBBB)
  453. ),
  454. borderRadius: BorderRadius.circular(8.0)
  455. ),
  456. padding: EdgeInsets.symmetric(horizontal: 16),
  457. child: DropdownButton<String>(
  458. value: _diametroVentilador,
  459. elevation: 16,
  460. style: GoogleFonts.roboto(
  461. color: Colors.black
  462. ),
  463. underline: Container(
  464. height: 0,
  465. color: Color(0x00000000),
  466. ),
  467. onChanged: (value){
  468. setState(() {
  469. _diametroVentilador = value!;
  470. });
  471. },
  472. items: _diametroUnidades.map<DropdownMenuItem<String>>((value){
  473. return DropdownMenuItem<String>(
  474. value: value,
  475. child: Text(
  476. value
  477. ),
  478. );
  479. }).toList(),
  480. ),
  481. ),
  482. SizedBox(width: 32.0)
  483. ],
  484. ),
  485. Container(
  486. margin: EdgeInsets.symmetric(vertical: 16.0, horizontal: 32.0),
  487. width: _screenSize.width,
  488. child: Text(
  489. 'Curva NC *',
  490. textAlign: TextAlign.start,
  491. style: GoogleFonts.roboto(
  492. color: Color(0xFF333333),
  493. fontWeight: FontWeight.w700,
  494. fontSize: 20.0
  495. ),
  496. ),
  497. ),
  498. Container(
  499. decoration: BoxDecoration(
  500. border: Border.all(
  501. color: Color(0xFFBBBBBB)
  502. ),
  503. borderRadius: BorderRadius.circular(8.0)
  504. ),
  505. padding: EdgeInsets.symmetric(horizontal: 16),
  506. child: DropdownButton<String>(
  507. value: _curvaNC,
  508. elevation: 16,
  509. underline: Container(
  510. height: 0,
  511. color: Color(0x00000000),
  512. ),
  513. onChanged: (value){
  514. setState(() {
  515. _curvaNC = value!;
  516. });
  517. },
  518. items: _curvas.map<DropdownMenuItem<String>>((value){
  519. return DropdownMenuItem<String>(
  520. value: value,
  521. child: Container(
  522. width: _screenSize.width-122.0,
  523. child: Text(
  524. value,
  525. textAlign: TextAlign.start,
  526. style: GoogleFonts.roboto(
  527. color: Colors.black
  528. ),
  529. ),
  530. ),
  531. );
  532. }).toList(),
  533. ),
  534. ),
  535. const SizedBox(height: 32.0),
  536. ElevatedButton(
  537. style: ElevatedButton.styleFrom(
  538. shape: RoundedRectangleBorder(
  539. borderRadius: BorderRadius.circular(50.0)
  540. ),
  541. primary: Color(0xFFEA2C13),
  542. padding: EdgeInsets.symmetric(vertical: 16.0, horizontal: 32.0),
  543. elevation: 0.0
  544. ),
  545. child: Text(
  546. 'Calcular',
  547. style: GoogleFonts.roboto(
  548. color: Colors.white,
  549. fontSize: 20.0,
  550. ),
  551. ),
  552. onPressed: _validaCampos,
  553. ),
  554. SizedBox(height: 32.0),
  555. ],
  556. ),
  557. ),
  558. ),
  559. );
  560. }
  561. void _validaCampos(){
  562. bool valido;
  563. int presicionDecimales = 8;
  564. Map<String, String> arrDatosCalculos = Map<String, String>();
  565. String tipoVentilador = _tipoVentilador;
  566. String modeloVentilador = _modeloVentilador;
  567. if(_ventiladoresTipos.indexOf(_tipoVentilador) < 1){
  568. _buildAlert('Tipo Ventilador');
  569. valido = false;
  570. return null;
  571. }
  572. if(_caudalController.text.isEmpty){
  573. _buildAlert('Caudal (Q)');
  574. valido = false;
  575. return null;
  576. }
  577. if(_presionController.text.isEmpty){
  578. _buildAlert('Presión Estatíca (P)');
  579. valido = false;
  580. return null;
  581. }
  582. if(_potenciaController.text.isEmpty){
  583. _buildAlert('Potencia Absorbida (Bhp)');
  584. valido = false;
  585. return null;
  586. }
  587. if(_diametroController.text.isEmpty){
  588. _buildAlert('Diametro del Ventilador');
  589. valido = false;
  590. return null;
  591. }
  592. double vCaudal = double.parse(double.parse(_caudalController.text).toStringAsFixed(presicionDecimales));
  593. double vPresEs = double.parse(double.parse(_presionController.text).toStringAsFixed(presicionDecimales));
  594. double vPoteAb = double.parse(double.parse(_potenciaController.text).toStringAsFixed(presicionDecimales));
  595. double vDiaVen = double.parse(double.parse(_diametroController.text).toStringAsFixed(presicionDecimales));
  596. arrDatosCalculos['VCAUDAL'] = '$vCaudal || $_caudal || CAUDAL';
  597. arrDatosCalculos['VPREE'] = '$vPresEs || $_presionEstatica || PRE';
  598. arrDatosCalculos['VPOTE'] = '$vPoteAb || $_potenciaAbsorbida || POTE';
  599. arrDatosCalculos['DIAME'] = '$vDiaVen || $_diametroVentilador || DIAME';
  600. valido = true;
  601. if(valido){
  602. _realizarCalculos(tipoVentilador, modeloVentilador, arrDatosCalculos, _curvaNC);
  603. }
  604. }
  605. void _buildAlert(String campo){
  606. showDialog(
  607. context: context,
  608. barrierDismissible: true,
  609. builder: (context) => AlertDialog(
  610. title: Text(
  611. 'Datos de Entrada Incompletos',
  612. ),
  613. content: Text(
  614. 'El campo <<$campo>> es un dato Requerido.'
  615. ),
  616. actions: [
  617. TextButton(
  618. child: Text(
  619. 'Continuar'
  620. ),
  621. onPressed: () => Navigator.of(context).pop(),
  622. )
  623. ],
  624. )
  625. );
  626. }
  627. double _log10(double num){
  628. return math.log(num)/math.ln10;
  629. }
  630. void _realizarCalculos(String tipo, String modelo, Map<String, String> datos, String curva){
  631. if(_atenuacion.isEmpty){
  632. _errorCarga('Hubo un error al cargar el Catálogo de Atenuadores');
  633. }else if(_potenciaSonora.isEmpty){
  634. _errorCarga('Hubo un error al cargar las Potencias Sonoras');
  635. }
  636. double vCaudal = 0.0;
  637. double vPresionE = 0.0;
  638. double vPotenciaA = 0.0;
  639. double vDiametro = 0.0;
  640. int presicionDecimales = 8;
  641. Map<String, String> arrDatosDeEntrada = Map<String, String>();
  642. Map<String, String> arrConversiones = Map<String, String>();
  643. List<String> arrFrecuencias = ["63Hz","125Hz","250Hz","500Hz","1000Hz","2000Hz","4000Hz","8000Hz"];
  644. List<double> arrPonderanciaA = [-26.2,-16.1,-8.6,-3.2,0.0,1.2,1.0,-1.1];
  645. arrDatosDeEntrada['TipoVentilador'] = tipo;
  646. arrDatosDeEntrada['ModeloVentilador'] = modelo;
  647. _ventiladores.forEach((element) {
  648. if(element.idmodelo == modelo){
  649. arrDatosDeEntrada['ModeloVentilador'] = element.idmodelo!;
  650. }
  651. });
  652. datos.forEach((key, value) {
  653. var splitDatos = value.split('||');
  654. var valorCampo = double.parse(splitDatos[0].trim());
  655. var unidadDeMedida = splitDatos[1].trim();
  656. var campoDato = splitDatos[2].trim();
  657. if ( campoDato == "CAUDAL" ) {
  658. arrDatosDeEntrada['Caudal'] = "$valorCampo $unidadDeMedida";
  659. switch ( unidadDeMedida ) { // Conversiones para la Caudal
  660. case 'M3/S':
  661. vCaudal = valorCampo / 0.0004719;
  662. var presicion = _precisarDecimales( presicionDecimales, vCaudal );
  663. arrConversiones['Caudal'] = "( $valorCampo $unidadDeMedida / 0.028314 M3/S ) X 1 CFM = $presicion CFM";
  664. break;
  665. case 'M3/MIN':
  666. vCaudal = valorCampo / 0.028314;
  667. var presicion = _precisarDecimales( presicionDecimales, vCaudal );
  668. arrConversiones['Caudal'] = "( $valorCampo $unidadDeMedida / 0.028314 M3/MIN ) X 1 CFM = $presicion CFM";
  669. break;
  670. case 'M3/H':
  671. vCaudal = valorCampo / 1.699011;
  672. var presicion = _precisarDecimales( presicionDecimales, vCaudal );
  673. arrConversiones['Caudal'] = "( $valorCampo $unidadDeMedida / 0.699011 M3/H ) X 1 CFM = $presicion CFM";
  674. break;
  675. case 'L/S':
  676. vCaudal = valorCampo * 2.119;
  677. var presicion = _precisarDecimales( presicionDecimales, vCaudal );
  678. arrConversiones['Caudal'] = "( $valorCampo $unidadDeMedida X 2.119 L/S ) X 1 CFM = $presicion CFM";
  679. break;
  680. case 'L/MIN':
  681. vCaudal = valorCampo / 28.32;
  682. var presicion = _precisarDecimales( presicionDecimales, vCaudal );
  683. arrConversiones['Caudal'] = "( $valorCampo $unidadDeMedida / 28.32 L/MIN ) X 1 CFM = $presicion CFM";
  684. break;
  685. case 'L/H':
  686. vCaudal = valorCampo / 1699;
  687. var presicion = _precisarDecimales( presicionDecimales, vCaudal );
  688. arrConversiones['Caudal'] = "( $valorCampo $unidadDeMedida / 1699 L/H ) X 1 CFM = $presicion CFM";
  689. break;
  690. case 'CM3/S':
  691. vCaudal = valorCampo / 471.9;
  692. var presicion = _precisarDecimales( presicionDecimales, vCaudal );
  693. arrConversiones['Caudal'] = "( $valorCampo $unidadDeMedida / 471.9 CM3/S ) X 1 CFM = $presicion CFM";
  694. arrConversiones[unidadDeMedida] = "$valorCampo / 471.9 = $vCaudal";
  695. break;
  696. case 'CM3/MIN':
  697. vCaudal = valorCampo / 28314;
  698. var presicion = _precisarDecimales( presicionDecimales, vCaudal );
  699. arrConversiones['Caudal'] = "( $valorCampo $unidadDeMedida / 278314 CM3/MIN ) X 1 CFM = $presicion CFM";
  700. break;
  701. case 'CM3/H':
  702. vCaudal = valorCampo / 1698840;
  703. var presicion = _precisarDecimales( presicionDecimales, vCaudal );
  704. arrConversiones['Caudal'] = "( $valorCampo $unidadDeMedida / 1698840 CM3/H ) X 1 CFM = $presicion CFM";
  705. break;
  706. case 'GALON/S':
  707. vCaudal = valorCampo / 0.12467532;
  708. var presicion = _precisarDecimales( presicionDecimales, vCaudal );
  709. arrConversiones['Caudal'] = "( $valorCampo $unidadDeMedida / 0.12467532 GALON/S) X 1 CFM = $presicion CFM";
  710. break;
  711. case 'GALON/MIN':
  712. vCaudal = valorCampo / 7.4805195566834;
  713. var presicion = _precisarDecimales( presicionDecimales, vCaudal );
  714. arrConversiones['Caudal'] = "( $valorCampo $unidadDeMedida / 7.4805195566834 GALON/MIN ) X 1 CFM = $presicion CFM";
  715. break;
  716. case 'GALON/H':
  717. vCaudal = valorCampo / 448.8311734;
  718. var presicion = _precisarDecimales( presicionDecimales, vCaudal );
  719. arrConversiones['Caudal'] = "( $valorCampo $unidadDeMedida / 448.8311734 GALON/H ) X 1 CFM = $presicion CFM";
  720. break;
  721. case 'CFM':
  722. vCaudal = valorCampo;
  723. break;
  724. }
  725. vCaudal = double.parse(vCaudal.toStringAsFixed(presicionDecimales));
  726. }
  727. if ( campoDato == "PRE" ) {
  728. arrDatosDeEntrada['PresionEstatica'] = "$valorCampo $unidadDeMedida";
  729. switch ( unidadDeMedida ) { // Conversiones para la Presión Estatíca
  730. case 'MPA':
  731. vPresionE = valorCampo * 401.47;
  732. var presicion = _precisarDecimales( presicionDecimales, vPresionE );
  733. arrConversiones['Presion Estatica'] = "( $valorCampo $unidadDeMedida X 401.47 MPA ) X 1 INWG = $presicion INWG";
  734. break;
  735. case 'KPA':
  736. vPresionE = valorCampo * 4.0147;
  737. var presicion = _precisarDecimales( presicionDecimales, vPresionE );
  738. arrConversiones['Presion Estatica'] = "( $valorCampo $unidadDeMedida X 4.0147 KPA ) X 1 INWG = $presicion INWG";
  739. break;
  740. case 'PA':
  741. vPresionE = valorCampo * 0.0040147;
  742. var presicion = _precisarDecimales( presicionDecimales, vPresionE );
  743. arrConversiones['Presion Estatica'] = "( $valorCampo $unidadDeMedida X 0.0040147 PA ) X 1 INWG = $presicion INWG";
  744. break;
  745. case 'BAR':
  746. vPresionE = valorCampo * 401.865;
  747. var presicion = _precisarDecimales( presicionDecimales, vPresionE );
  748. arrConversiones['Presion Estatica'] = "( $valorCampo $unidadDeMedida X 401.865 BAR ) X 1 INWG = $presicion INWG";
  749. break;
  750. case 'M CA':
  751. vPresionE = valorCampo * 39.166667;
  752. var presicion = _precisarDecimales( presicionDecimales, vPresionE );
  753. arrConversiones['Presion Estatica'] = "( $valorCampo $unidadDeMedida X 39.166667 ) X 1 INWG = $presicion INWG";
  754. break;
  755. case 'CM CA':
  756. vPresionE = valorCampo * 0.39166667;
  757. var presicion = _precisarDecimales( presicionDecimales, vPresionE );
  758. arrConversiones['Presion Estatica'] = "( $valorCampo $unidadDeMedida X 0.39166667 CM CA ) X 1 INWG = $presicion INWG";
  759. break;
  760. case 'MM CA':
  761. vPresionE = valorCampo * 0.039166667;
  762. var presicion = _precisarDecimales( presicionDecimales, vPresionE );
  763. arrConversiones['Presion Estatica'] = "( $valorCampo $unidadDeMedida X 0.039166667 MM CA ) X 1 INWG = $presicion INWG";
  764. break;
  765. case 'IN HG':
  766. vPresionE = valorCampo / 0.0735541043;
  767. var presicion = _precisarDecimales( presicionDecimales, vPresionE );
  768. arrConversiones['Presion Estatica'] = "( $valorCampo $unidadDeMedida X 0.0735541043 ) X 1 INWG = $presicion INWG";
  769. break;
  770. case 'CM HG':
  771. vPresionE = valorCampo / 0.18682743044;
  772. var presicion = _precisarDecimales( presicionDecimales, vPresionE );
  773. arrConversiones['Presion Estatica'] = "( $valorCampo $unidadDeMedida X 0.18682743044 CM HG ) X 1 INWG = $presicion INWG";
  774. break;
  775. case 'MM HG':
  776. vPresionE = valorCampo / 0.018682743044;
  777. var presicion = _precisarDecimales( presicionDecimales, vPresionE );
  778. arrConversiones['Presion Estatica'] = "( $valorCampo $unidadDeMedida X 0.018682743044 MM HG ) X 1 INWG = $presicion INWG";
  779. break;
  780. case 'TORR':
  781. vPresionE = valorCampo * 0.5352533071;
  782. var presicion = _precisarDecimales( presicionDecimales, vPresionE );
  783. arrConversiones['Presion Estatica'] = "( $valorCampo $unidadDeMedida X 0.5352533071 TORR ) X 1 INWG = $presicion INWG";
  784. break;
  785. case 'INWG':
  786. vPresionE = valorCampo;
  787. break;
  788. }
  789. vPresionE = double.parse(vPresionE.toStringAsFixed(presicionDecimales));
  790. }
  791. if ( campoDato == "POTE" ) {
  792. arrDatosDeEntrada['PotenciaAbsorbida'] = "$valorCampo $unidadDeMedida";
  793. switch ( unidadDeMedida ) { // Conversiones para la Potencia Absorbida
  794. case 'HP':
  795. vPotenciaA = valorCampo / 13.1549;
  796. var presicion = _precisarDecimales( presicionDecimales, vPotenciaA );
  797. arrConversiones['Potencia Absorbida'] = "( $valorCampo $unidadDeMedida / 13.1549 HP ) X 1 BHP = $presicion BHP";
  798. break;
  799. case 'J/S':
  800. vPotenciaA = valorCampo / 9809.5;
  801. var presicion = _precisarDecimales( presicionDecimales, vPotenciaA );
  802. arrConversiones['Potencia Absorbida'] = "( $valorCampo $unidadDeMedida / 9809.5 J/S ) X 1 BHP = $presicion BHP";
  803. break;
  804. case 'KCAL/H':
  805. vPotenciaA = valorCampo / 8434.65;
  806. var presicion = _precisarDecimales( presicionDecimales, vPotenciaA );
  807. arrConversiones['Potencia Absorbida'] = "( $valorCampo $unidadDeMedida / 8434.65 KCAL ) X 1 BHP = $presicion BHP";
  808. break;
  809. case 'KW':
  810. vPotenciaA = valorCampo / 9.8095;
  811. var presicion = _precisarDecimales( presicionDecimales, vPotenciaA );
  812. arrConversiones['Potencia Absorbida'] = "( $valorCampo $unidadDeMedida / 8434.65 KW ) X 1 BHP = $presicion BHP";
  813. break;
  814. case 'WATT':
  815. vPotenciaA = valorCampo / 9809.5;
  816. var presicion = _precisarDecimales( presicionDecimales, vPotenciaA );
  817. arrConversiones['Potencia Absorbida'] = "( $valorCampo $unidadDeMedida / 8434.65 WATT ) X 1 BHP = $presicion BHP";
  818. break;
  819. case 'PIE-LIBRA(S)':
  820. vPotenciaA = valorCampo / 7235.12;
  821. var presicion = _precisarDecimales( presicionDecimales, vPotenciaA );
  822. arrConversiones['Potencia Absorbida'] = "( $valorCampo $unidadDeMedida / 8434.65 PIE-LIBRA(S) ) X 1 BHP = $presicion BHP";
  823. break;
  824. case 'PIE-LIBRA(M)':
  825. vPotenciaA = valorCampo / 434106.95;
  826. var presicion = _precisarDecimales( presicionDecimales, vPotenciaA );
  827. arrConversiones['Potencia Absorbida'] = "( $valorCampo $unidadDeMedida / 8434.65 PIE-LIBRA(M) ) X 1 BHP = $presicion BHP";
  828. break;
  829. case 'BHP':
  830. vPotenciaA = valorCampo;
  831. break;
  832. }
  833. vPotenciaA = double.parse(vPotenciaA.toStringAsFixed(presicionDecimales));
  834. }
  835. if ( campoDato == "DIAME" ) {
  836. arrDatosDeEntrada['Diametro'] = "$valorCampo $unidadDeMedida";
  837. switch ( unidadDeMedida ) { // Conversiones para el Diametro
  838. case 'MM':
  839. vDiametro = (valorCampo * 3.291) / 1000;
  840. var presicion = _precisarDecimales( presicionDecimales, vDiametro );
  841. arrConversiones['Diametro'] = "() ( $valorCampo $unidadDeMedida X 3.291 MM ) / 1000 ) X 1 FT = $presicion FT";
  842. break;
  843. case 'CM':
  844. vDiametro = (valorCampo * 3.291) / 100;
  845. var presicion = _precisarDecimales( presicionDecimales, vDiametro );
  846. arrConversiones['Diametro'] = "( ( $valorCampo $unidadDeMedida X 3.291 CM ) / 100 ) X 1 FT = $presicion FT";
  847. break;
  848. case 'DM':
  849. vDiametro = (valorCampo * 3.291) / 10;
  850. var presicion = _precisarDecimales( presicionDecimales, vDiametro );
  851. arrConversiones['Diametro'] = "( ( $valorCampo $unidadDeMedida X 13.1549 DM ) / 10 ) X 1 FT = $presicion FT";
  852. break;
  853. case 'M':
  854. vDiametro = valorCampo * 3.291;
  855. var presicion = _precisarDecimales( presicionDecimales, vDiametro );
  856. arrConversiones['Diametro'] = "( $valorCampo $unidadDeMedida X 13.1549 M ) X 1 FT = $presicion FT";
  857. arrConversiones[unidadDeMedida] = "$valorCampo X 13.1549 = $vDiametro ";
  858. break;
  859. case 'MI':
  860. vDiametro = valorCampo * 5280;
  861. var presicion = _precisarDecimales( presicionDecimales, vDiametro );
  862. arrConversiones['Diametro'] = "( $valorCampo $unidadDeMedida X 5280 MI ) X 1 FT = $presicion FT";
  863. break;
  864. case 'YARDA':
  865. vDiametro = valorCampo / 3;
  866. var presicion = _precisarDecimales( presicionDecimales, vDiametro );
  867. arrConversiones['Diametro'] = "( $valorCampo $unidadDeMedida / 3 YARDA ) X 1 FT = $presicion FT";
  868. break;
  869. case 'INCH':
  870. vDiametro = valorCampo * 0.083333;
  871. var presicion = _precisarDecimales( presicionDecimales, vDiametro );
  872. arrConversiones['Diametro'] = "( $valorCampo $unidadDeMedida X 0.083333 MM ) X 1 FT = $presicion FT";
  873. break;
  874. case 'FT':
  875. vDiametro = valorCampo;
  876. break;
  877. }
  878. vDiametro = double.parse(vDiametro.toStringAsFixed(presicionDecimales));
  879. }
  880. });
  881. Ventilador arrDatosVentilador = Ventilador();
  882. _ventiladores.forEach((ventilador) {
  883. if(ventilador.tipo == tipo){
  884. if(ventilador.desc == modelo || ventilador.modelo == modelo){
  885. arrDatosVentilador = ventilador;
  886. }
  887. }
  888. });
  889. List<int> arrCurvaNC = [];
  890. switch(curva){
  891. case 'NC15':
  892. arrDatosDeEntrada['CurvaNC'] = "$curva##[ 47, 36, 29, 22, 17, 14, 12, 11 ]";
  893. arrCurvaNC = [ 47, 36, 29, 22, 17, 14, 12, 11 ];
  894. break;
  895. case 'NC20':
  896. arrDatosDeEntrada['CurvaNC'] = "$curva##[ 51, 40, 33, 26, 22, 19, 17, 16 ]";
  897. arrCurvaNC = [ 51, 40, 33, 26, 22, 19, 17, 16 ];
  898. break;
  899. case 'NC25':
  900. arrDatosDeEntrada['CurvaNC'] = "$curva##[ 54, 44, 37, 31, 27, 24, 22, 21 ]";
  901. arrCurvaNC = [ 54, 44, 37, 31, 27, 24, 22, 21 ];
  902. break;
  903. case 'NC30':
  904. arrDatosDeEntrada['CurvaNC'] = "$curva##[ 57, 48, 41, 35, 31, 29, 28, 27 ]";
  905. arrCurvaNC = [ 57, 48, 41, 35, 31, 29, 28, 27 ];
  906. break;
  907. case 'NC35':
  908. arrDatosDeEntrada['CurvaNC'] = "$curva##[ 60, 52, 45, 40, 36, 34, 33, 32 ]";
  909. arrCurvaNC = [ 60, 52, 45, 40, 36, 34, 33, 32 ];
  910. break;
  911. case 'NC40':
  912. arrDatosDeEntrada['CurvaNC'] = "$curva##[ 64, 56, 50, 45, 41, 39, 38, 37 ]";
  913. arrCurvaNC = [ 64, 56, 50, 45, 41, 39, 38, 37 ];
  914. break;
  915. case 'NC45':
  916. arrDatosDeEntrada['CurvaNC'] = "$curva##[ 67, 60, 54, 49, 46, 44, 43, 42 ]";
  917. arrCurvaNC = [ 67, 60, 54, 49, 46, 44, 43, 42 ];
  918. break;
  919. case 'NC50':
  920. arrDatosDeEntrada['CurvaNC'] = "$curva##[ 71, 64, 58, 54, 51, 49, 48, 47 ]";
  921. arrCurvaNC = [ 71, 64, 58, 54, 51, 49, 48, 47 ];
  922. break;
  923. case 'NC55':
  924. arrDatosDeEntrada['CurvaNC'] = "$curva##[ 74, 67, 62, 58, 56, 54, 53, 52 ]";
  925. arrCurvaNC = [ 74, 67, 62, 58, 56, 54, 53, 52 ];
  926. break;
  927. case 'NC60':
  928. arrDatosDeEntrada['CurvaNC'] = "$curva##[ 77, 71, 67, 63, 61, 59, 58, 57 ]";
  929. arrCurvaNC = [ 77, 71, 67, 63, 61, 59, 58, 57 ];
  930. break;
  931. case 'NC65':
  932. arrDatosDeEntrada['CurvaNC'] = "$curva##[ 80, 75, 71, 68, 66, 64, 63, 62 ]";
  933. arrCurvaNC = [ 80, 75, 71, 68, 66, 64, 63, 62 ];
  934. break;
  935. case 'NC70':
  936. arrDatosDeEntrada['CurvaNC'] = "$curva##[ 84, 79, 75, 72, 71, 70, 68, 68 ]";
  937. arrCurvaNC = [ 84, 79, 75, 72, 71, 70, 68, 68 ];
  938. break;
  939. }
  940. double pi = math.pi;
  941. double a = ((pi) * (math.pow(vDiametro, 2))) / 4;
  942. a = double.parse(a.toStringAsFixed(presicionDecimales));
  943. double v = vCaudal / a;
  944. v = double.parse(v.toStringAsFixed(presicionDecimales));
  945. Map<String, String> arrLw = Map<String, String>();
  946. Map<String, double> arrKw = Map<String, double>();
  947. if(arrFrecuencias.length != 0){
  948. arrFrecuencias.forEach((indice) {
  949. String frecuencia = indice;
  950. double kw = (10 * _log10(vCaudal)) + (20 * _log10(vPresionE));
  951. String cadenaOperacion = "(10 x ${_log10(vCaudal)}) + (20 x ${_log10(vPresionE)}) = / $kw /";
  952. kw = double.parse(kw.toStringAsFixed(presicionDecimales));
  953. arrLw[frecuencia] = frecuencia == arrFrecuencias[0] ? arrDatosVentilador.the63Hz!
  954. : frecuencia == arrFrecuencias[1] ? arrDatosVentilador.the125Hz!
  955. : frecuencia == arrFrecuencias[2] ? arrDatosVentilador.the250Hz!
  956. : frecuencia == arrFrecuencias[3] ? arrDatosVentilador.the500Hz!
  957. : frecuencia == arrFrecuencias[4] ? arrDatosVentilador.the1000Hz!
  958. : frecuencia == arrFrecuencias[5] ? arrDatosVentilador.the2000Hz!
  959. : frecuencia == arrFrecuencias[6] ? arrDatosVentilador.the4000Hz!
  960. : arrDatosVentilador.the8000Hz!;
  961. arrKw[frecuencia] = kw;
  962. });
  963. }
  964. Map<String, double> arrLwFinal = Map<String, double>();
  965. if(arrLw.length != 0){
  966. arrLw.forEach((key, value) {
  967. String valorLw = arrLw[key]!;
  968. double valorKw = arrKw[key]!;
  969. double lwFinal = valorKw + double.parse(valorLw);
  970. String cadenaOperacion = "$valorKw + $valorLw = / $lwFinal /";
  971. lwFinal = double.parse(lwFinal.toStringAsFixed(presicionDecimales));
  972. arrLwFinal[key] = lwFinal;
  973. });
  974. }
  975. Map<String, double> arrLwA = Map<String, double>();
  976. if(arrPonderanciaA.length != 0){
  977. arrPonderanciaA.forEach((element) {
  978. double valorLwFinal = arrLwFinal[arrFrecuencias[arrPonderanciaA.indexOf(element)]]!;
  979. double valorPonderancia = element;
  980. double lwA = valorLwFinal + valorPonderancia;
  981. String cadenaOperacion = "$valorLwFinal + $valorPonderancia = / $lwA /";
  982. lwA = double.parse(lwA.toStringAsFixed(presicionDecimales));
  983. arrLwA[arrFrecuencias[arrPonderanciaA.indexOf(element)]] = lwA;
  984. });
  985. }
  986. Map<String, double> arrLwAVentiladorSeleccionado = Map<String, double>();
  987. if(arrCurvaNC.length != 0){
  988. arrCurvaNC.forEach((element) {
  989. double valorLwFinal = arrLwFinal[arrFrecuencias[arrCurvaNC.indexOf(element)]]!;
  990. double valorCurvaNC = element.toDouble();
  991. double lwAVentilador = valorLwFinal - valorCurvaNC;
  992. String cadenaOperacion = "$valorLwFinal - $valorCurvaNC = / $lwAVentilador /";
  993. lwAVentilador = double.parse(lwAVentilador.toStringAsFixed(presicionDecimales));
  994. arrLwAVentiladorSeleccionado[arrFrecuencias[arrCurvaNC.indexOf(element)]] = lwAVentilador;
  995. });
  996. }
  997. double vAtenuador100Hz;
  998. if(arrLwAVentiladorSeleccionado.length != 0){
  999. vAtenuador100Hz = arrLwAVentiladorSeleccionado["1000Hz"]!;
  1000. }else{
  1001. Fluttertoast.showToast(
  1002. msg: 'Error al cargar los valores de LwA del Ventilador',
  1003. toastLength: Toast.LENGTH_LONG,
  1004. timeInSecForIosWeb: 3,
  1005. gravity: ToastGravity.CENTER
  1006. );
  1007. return;
  1008. }
  1009. double diametroTmp = vDiametro * 304.8;
  1010. diametroTmp = double.parse(diametroTmp.toStringAsFixed(presicionDecimales));
  1011. if ( diametroTmp <= 425 ) {
  1012. diametroTmp = 400;
  1013. } else if ( (diametroTmp > 425) && (diametroTmp <= 475) ) {
  1014. diametroTmp = 450;
  1015. } else if ( (diametroTmp > 475) && (diametroTmp <= 525) ) {
  1016. diametroTmp = 500;
  1017. } else if ( (diametroTmp > 525) && (diametroTmp <= 575) ) {
  1018. diametroTmp = 560;
  1019. } else if ( (diametroTmp > 580) && (diametroTmp <= 615) ) {
  1020. diametroTmp = 600;
  1021. } else if ( (diametroTmp > 615) && (diametroTmp <= 655) ) {
  1022. diametroTmp = 630;
  1023. } else if ( (diametroTmp > 655) && (diametroTmp <= 695) ) {
  1024. diametroTmp = 675;
  1025. } else if ( (diametroTmp > 695) && (diametroTmp <= 730) ) {
  1026. diametroTmp = 710;
  1027. } else if ( (diametroTmp > 730) && (diametroTmp <= 775) ) {
  1028. diametroTmp = 750;
  1029. } else if ( (diametroTmp > 775) && (diametroTmp <= 820) ) {
  1030. diametroTmp = 800;
  1031. } else if ( (diametroTmp > 820) && (diametroTmp <= 870) ) {
  1032. diametroTmp = 840;
  1033. } else if ( (diametroTmp > 870) && (diametroTmp <= 920) ) {
  1034. diametroTmp = 900;
  1035. } else if ( (diametroTmp > 920) && (diametroTmp <= 970) ) {
  1036. diametroTmp = 945;
  1037. } else if ( (diametroTmp > 970) && (diametroTmp <= 1030) ) {
  1038. diametroTmp = 1000;
  1039. } else if ( (diametroTmp > 1030) && (diametroTmp <= 1090) ) {
  1040. diametroTmp = 1065;
  1041. } else if ( (diametroTmp > 1090) && (diametroTmp <= 1160) ) {
  1042. diametroTmp = 1120;
  1043. } else if ( (diametroTmp > 1160) && (diametroTmp <= 1225) ) {
  1044. diametroTmp = 1200;
  1045. } else if ( (diametroTmp > 1225) && (diametroTmp <= 1255) ) {
  1046. diametroTmp = 1250;
  1047. } else if ( (diametroTmp > 1255) && (diametroTmp <= 1305) ) {
  1048. diametroTmp = 1260;
  1049. } else if ( (diametroTmp > 1305) && (diametroTmp <= 1375) ) {
  1050. diametroTmp = 1350;
  1051. } else if ( (diametroTmp > 1375) && (diametroTmp <= 1410) ) {
  1052. diametroTmp = 1400;
  1053. } else if ( (diametroTmp > 1410) && (diametroTmp <= 1460) ) {
  1054. diametroTmp = 1420;
  1055. } else if ( (diametroTmp > 1460) && (diametroTmp <= 1550) ) {
  1056. diametroTmp = 1500;
  1057. } else if ( (diametroTmp > 1550) && (diametroTmp <= 1640) ) {
  1058. diametroTmp = 1600;
  1059. } else if ( (diametroTmp > 1640) && (diametroTmp <= 1740) ) {
  1060. diametroTmp = 1680;
  1061. } else if ( (diametroTmp > 1740) && (diametroTmp <= 1840) ) {
  1062. diametroTmp = 1800;
  1063. } else if ( (diametroTmp > 1840) && (diametroTmp <= 1885) ) {
  1064. diametroTmp = 1875;
  1065. } else if ( (diametroTmp > 1885) && (diametroTmp <= 2050) ) {
  1066. diametroTmp = 2000;
  1067. } else if ( (diametroTmp > 2050) && (diametroTmp <= 2170) ) {
  1068. diametroTmp = 2100;
  1069. } else if ( (diametroTmp > 2170) && (diametroTmp <= 2370) ) {
  1070. diametroTmp = 2240;
  1071. } else if ( (diametroTmp > 2370) && (diametroTmp <= 2750) ) {
  1072. diametroTmp = 2500;
  1073. } else if ( (diametroTmp > 2501) && (diametroTmp <= 3000) ) {
  1074. diametroTmp = 2800;
  1075. }
  1076. Map<String, String> arrAtenuador1000Hz = Map<String, String>();
  1077. _atenuacion.forEach((element) {
  1078. String idAtenuador = element.idatenuacion!;
  1079. String vDiametroAte = element.diametro!;
  1080. String vLongitudAte = element.longitud!;
  1081. String v1000Hz = element.the1000Hz!;
  1082. if(vDiametroAte == diametroTmp.toInt().toString()){
  1083. arrAtenuador1000Hz[idAtenuador] = v1000Hz;
  1084. }
  1085. });
  1086. Map<String, double> arrDiferencia = Map<String, double>();
  1087. Map<String, double> arrDiferenciaSort = Map<String, double>();
  1088. String idAtenuadorSelect;
  1089. if(arrAtenuador1000Hz.length > 0){
  1090. arrAtenuador1000Hz.forEach((key, value) {
  1091. double vAtenuadorSelect = double.parse(arrAtenuador1000Hz[key]!);
  1092. double diferencia;
  1093. if(vAtenuador100Hz > vAtenuadorSelect){
  1094. diferencia = vAtenuador100Hz - vAtenuadorSelect;
  1095. }else{
  1096. diferencia = vAtenuadorSelect - vAtenuador100Hz;
  1097. }
  1098. diferencia = double.parse(diferencia.toStringAsFixed(presicionDecimales));
  1099. arrDiferencia[key] = diferencia;
  1100. arrDiferenciaSort[key] = diferencia;
  1101. });
  1102. arrDiferenciaSort = _sortMapItems(arrDiferenciaSort);
  1103. double valMenorDif = arrDiferenciaSort[arrDiferenciaSort.keys.first]!;
  1104. idAtenuadorSelect = _getKey(arrDiferencia, valMenorDif);
  1105. }else{
  1106. Fluttertoast.showToast(
  1107. msg: 'Se Presento un Error a la hora de cargar los valores de los posibles atenuadores seleccionados.',
  1108. toastLength: Toast.LENGTH_LONG,
  1109. timeInSecForIosWeb: 3,
  1110. gravity: ToastGravity.CENTER
  1111. );
  1112. return null;
  1113. }
  1114. Atenuacion arrAtenuador = Atenuacion();
  1115. _atenuacion.forEach((element) {
  1116. String idAtenuador = element.idatenuacion!;
  1117. if(idAtenuador == idAtenuadorSelect){
  1118. arrAtenuador = element;
  1119. }
  1120. });
  1121. Map<String, double> arrLwAVentilador = Map<String, double>();
  1122. arrFrecuencias.forEach((element) {
  1123. String frecuencia = element;
  1124. double vlwFinal = arrLwFinal[frecuencia]!;
  1125. String vAtenuador = frecuencia == arrFrecuencias[0] ? arrAtenuador.the63Hz!
  1126. : frecuencia == arrFrecuencias[1] ? arrAtenuador.the125Hz!
  1127. : frecuencia == arrFrecuencias[2] ? arrAtenuador.the250Hz!
  1128. : frecuencia == arrFrecuencias[3] ? arrAtenuador.the500Hz!
  1129. : frecuencia == arrFrecuencias[4] ? arrAtenuador.the1000Hz!
  1130. : frecuencia == arrFrecuencias[5] ? arrAtenuador.the2000Hz!
  1131. : frecuencia == arrFrecuencias[6] ? arrAtenuador.the4000Hz!
  1132. : arrAtenuador.the8000Hz!;
  1133. double lwAVentilador = vlwFinal - double.parse(vAtenuador);
  1134. String cadenaOperacion = "$vlwFinal - $vAtenuador = $lwAVentilador";
  1135. lwAVentilador = double.parse(lwAVentilador.toStringAsFixed(presicionDecimales));
  1136. arrLwAVentilador[frecuencia] = lwAVentilador;
  1137. });
  1138. String searchPotenciaSonora = '';
  1139. if(!v.isNaN){
  1140. double tmpPotenciaSonora = v;
  1141. if ( tmpPotenciaSonora <= 1000 ) {
  1142. searchPotenciaSonora = "<1000";
  1143. } else if ( (tmpPotenciaSonora > 1000) && (tmpPotenciaSonora <= 1500) ) {
  1144. searchPotenciaSonora = ">1000";
  1145. } else if ( (tmpPotenciaSonora > 1500) && (tmpPotenciaSonora <= 2000) ) {
  1146. searchPotenciaSonora = "<2000";
  1147. } else if ( (tmpPotenciaSonora > 2000) && (tmpPotenciaSonora <= 2500) ) {
  1148. searchPotenciaSonora = ">2000";
  1149. } else if ( (tmpPotenciaSonora > 2500) && (tmpPotenciaSonora <= 3000) ) {
  1150. searchPotenciaSonora = "<3000";
  1151. } else if ( tmpPotenciaSonora > 3000 ) {
  1152. searchPotenciaSonora = ">3000";
  1153. }
  1154. }
  1155. PotenciaSonora arrPotenciaSonoraSelect = PotenciaSonora();
  1156. _potenciaSonora.forEach((element) {
  1157. PotenciaSonora arrTmpPotencia = element;
  1158. String idPotenciaSonora = element.idpotson!;
  1159. String vFtMin = element.ftmin!;
  1160. if(vFtMin == searchPotenciaSonora){
  1161. arrPotenciaSonoraSelect = arrTmpPotencia;
  1162. }
  1163. });
  1164. Map<String, String> arrSonidoRegenerado = Map<String, String>();
  1165. if(arrAtenuador1000Hz.length > 0){
  1166. arrFrecuencias.forEach((element) {
  1167. String frecuencia = element;
  1168. arrSonidoRegenerado[frecuencia] = frecuencia == arrFrecuencias[0] ? arrPotenciaSonoraSelect.the63Hz!
  1169. : frecuencia == arrFrecuencias[1] ? arrPotenciaSonoraSelect.the125Hz!
  1170. : frecuencia == arrFrecuencias[2] ? arrPotenciaSonoraSelect.the250Hz!
  1171. : frecuencia == arrFrecuencias[3] ? arrPotenciaSonoraSelect.the500Hz!
  1172. : frecuencia == arrFrecuencias[4] ? arrPotenciaSonoraSelect.the1000Hz!
  1173. : frecuencia == arrFrecuencias[5] ? arrPotenciaSonoraSelect.the2000Hz!
  1174. : frecuencia == arrFrecuencias[6] ? arrPotenciaSonoraSelect.the4000Hz!
  1175. : arrPotenciaSonoraSelect.the8000Hz!;
  1176. });
  1177. }else{
  1178. Fluttertoast.showToast(
  1179. msg: 'Los valores de las Frecuencias Hz del atenudor seleccionado, se no se cargaron correctamente.',
  1180. toastLength: Toast.LENGTH_LONG,
  1181. timeInSecForIosWeb: 3,
  1182. gravity: ToastGravity.CENTER
  1183. );
  1184. return;
  1185. }
  1186. Map<String, double> arrCorreccionArea = Map<String, double>();
  1187. for(int i = 0; i < arrFrecuencias.length; i++){
  1188. String frecuencia = arrFrecuencias[i];
  1189. double correccionArea = (10 * _log10(a)) - 4.8;
  1190. String cadenaOperacion = "(10 x ${_log10(a)}) - 4.8";
  1191. correccionArea = double.parse(correccionArea.toStringAsFixed(presicionDecimales));
  1192. arrCorreccionArea[frecuencia] = correccionArea;
  1193. }
  1194. Map<String, double> arrSonidoMasCorreccion = Map<String, double>();
  1195. for(int i = 0; i < arrFrecuencias.length; i++){
  1196. String frecuencia = arrFrecuencias[i];
  1197. double valPotenciaSonora = double.parse(frecuencia == arrFrecuencias[0] ? arrPotenciaSonoraSelect.the63Hz!
  1198. : frecuencia == arrFrecuencias[1] ? arrPotenciaSonoraSelect.the125Hz!
  1199. : frecuencia == arrFrecuencias[2] ? arrPotenciaSonoraSelect.the250Hz!
  1200. : frecuencia == arrFrecuencias[3] ? arrPotenciaSonoraSelect.the500Hz!
  1201. : frecuencia == arrFrecuencias[4] ? arrPotenciaSonoraSelect.the1000Hz!
  1202. : frecuencia == arrFrecuencias[5] ? arrPotenciaSonoraSelect.the2000Hz!
  1203. : frecuencia == arrFrecuencias[6] ? arrPotenciaSonoraSelect.the4000Hz!
  1204. : arrPotenciaSonoraSelect.the8000Hz!
  1205. );
  1206. double valCorreccionArea = arrCorreccionArea[frecuencia]!;
  1207. double sonidoMasCorreccion = valPotenciaSonora + valCorreccionArea;
  1208. String cadenaOperacion = "$valPotenciaSonora + $valCorreccionArea = $sonidoMasCorreccion";
  1209. sonidoMasCorreccion = double.parse(sonidoMasCorreccion.toStringAsFixed(presicionDecimales));
  1210. arrSonidoMasCorreccion[frecuencia] = sonidoMasCorreccion;
  1211. }
  1212. Map<String, double> arrSumaLog = Map<String, double>();
  1213. for(int i = 0; i < arrFrecuencias.length; i++){
  1214. if(arrLwAVentilador.length > 0){
  1215. String frecuencia = arrFrecuencias[i];
  1216. double potSonora = double.parse(frecuencia == arrFrecuencias[0] ? arrPotenciaSonoraSelect.the63Hz!
  1217. : frecuencia == arrFrecuencias[1] ? arrPotenciaSonoraSelect.the125Hz!
  1218. : frecuencia == arrFrecuencias[2] ? arrPotenciaSonoraSelect.the250Hz!
  1219. : frecuencia == arrFrecuencias[3] ? arrPotenciaSonoraSelect.the500Hz!
  1220. : frecuencia == arrFrecuencias[4] ? arrPotenciaSonoraSelect.the1000Hz!
  1221. : frecuencia == arrFrecuencias[5] ? arrPotenciaSonoraSelect.the2000Hz!
  1222. : frecuencia == arrFrecuencias[6] ? arrPotenciaSonoraSelect.the4000Hz!
  1223. : arrPotenciaSonoraSelect.the8000Hz!
  1224. );
  1225. double sumaLog = 10 * (_log10((math.pow(10, (arrLwAVentilador[frecuencia]!/10))) + (math.pow(10, (potSonora/10))).toDouble()));
  1226. sumaLog = double.parse(sumaLog.toStringAsFixed(presicionDecimales));
  1227. arrSumaLog[frecuencia] = sumaLog;
  1228. }
  1229. }
  1230. Map<String, double> arrEspectroResultante = Map<String, double>();
  1231. for(int i = 0; i < arrFrecuencias.length; i++){
  1232. String frecuencia = arrFrecuencias[i];
  1233. if(arrSumaLog.length > 0 && arrPonderanciaA.length > 0){
  1234. double espectroResultante = arrSumaLog[frecuencia]! + arrPonderanciaA[i];
  1235. espectroResultante = double.parse(espectroResultante.toStringAsFixed(presicionDecimales));
  1236. arrEspectroResultante[frecuencia] = espectroResultante;
  1237. }
  1238. }
  1239. double sumaLogaritmica;
  1240. if(arrEspectroResultante.length > 0){
  1241. sumaLogaritmica = 10 * (_log10(math.pow(10, (arrEspectroResultante["63Hz"]!/10)) + math.pow(10, (arrEspectroResultante["125Hz"]!/10)).toDouble()
  1242. + math.pow(10, (arrEspectroResultante["250Hz"]!/10)) + math.pow(10, (arrEspectroResultante["500Hz"]!/10)).toDouble()
  1243. + math.pow(10, (arrEspectroResultante["1000Hz"]!/10)) + math.pow(10, (arrEspectroResultante["2000Hz"]!/10)).toDouble()
  1244. + math.pow(10, (arrEspectroResultante["4000Hz"]!/10)) + math.pow(10, (arrEspectroResultante["8000Hz"]!/10)).toDouble()
  1245. ));
  1246. sumaLogaritmica = double.parse(sumaLogaritmica.toStringAsFixed(presicionDecimales));
  1247. }
  1248. double sumaLogaritmicaLwFinal = 0.0;
  1249. if(arrLwFinal.length > 0){
  1250. sumaLogaritmicaLwFinal = 10 * (_log10(math.pow(10, (arrLwFinal["63Hz"]!/10)) + math.pow(10, (arrLwFinal["125Hz"]!/10)).toDouble()
  1251. + math.pow(10, (arrLwFinal["250Hz"]!/10)) + math.pow(10, (arrLwFinal["500Hz"]!/10)).toDouble()
  1252. + math.pow(10, (arrLwFinal["1000Hz"]!/10)) + math.pow(10, (arrLwFinal["2000Hz"]!/10)).toDouble()
  1253. + math.pow(10, (arrLwFinal["4000Hz"]!/10)) + math.pow(10, (arrLwFinal["8000Hz"]!/10)).toDouble()
  1254. ));
  1255. sumaLogaritmicaLwFinal = double.parse(sumaLogaritmicaLwFinal.toStringAsFixed(presicionDecimales));
  1256. }
  1257. double sumaLogaritmicaLwA = 0.0;
  1258. if(arrLwA.length > 0){
  1259. sumaLogaritmicaLwA = 10 * (_log10(math.pow(10, (arrLwA["63Hz"]!/10)) + math.pow(10, (arrLwA["125Hz"]!/10)).toDouble()
  1260. + math.pow(10, (arrLwA["250Hz"]!/10)) + math.pow(10, (arrLwA["500Hz"]!/10)).toDouble()
  1261. + math.pow(10, (arrLwA["1000Hz"]!/10)) + math.pow(10, (arrLwA["2000Hz"]!/10)).toDouble()
  1262. + math.pow(10, (arrLwA["4000Hz"]!/10)) + math.pow(10, (arrLwA["8000Hz"]!/10)).toDouble()
  1263. ));
  1264. sumaLogaritmicaLwA = double.parse(sumaLogaritmicaLwA.toStringAsFixed(presicionDecimales));
  1265. }
  1266. double resultadoPresionSonora = sumaLogaritmicaLwFinal - (10 * _log10((4*math.pi)*(math.pow(1.5, 2)/2)));
  1267. resultadoPresionSonora = double.parse(resultadoPresionSonora.toStringAsFixed(presicionDecimales));
  1268. double resultadoPresionSonoraA = sumaLogaritmicaLwA - (10 * _log10((4 * math.pi) * (math.pow(1.5, 2) / 2)));
  1269. resultadoPresionSonoraA = double.parse(resultadoPresionSonoraA.toStringAsFixed(presicionDecimales));
  1270. double sumaLogaritmicaLwAtenuado = 0.0;
  1271. if(arrSumaLog.length > 0){
  1272. sumaLogaritmicaLwAtenuado = 10 * (_log10(math.pow(10, (arrSumaLog["63Hz"]!/10)) + math.pow(10, (arrSumaLog["125Hz"]!/10)).toDouble()
  1273. + math.pow(10, (arrSumaLog["250Hz"]!/10)) + math.pow(10, (arrSumaLog["500Hz"]!/10)).toDouble()
  1274. + math.pow(10, (arrSumaLog["1000Hz"]!/10)) + math.pow(10, (arrSumaLog["2000Hz"]!/10)).toDouble()
  1275. + math.pow(10, (arrSumaLog["4000Hz"]!/10)) + math.pow(10, (arrSumaLog["8000Hz"]!/10)).toDouble()
  1276. ));
  1277. sumaLogaritmicaLwAtenuado = double.parse(sumaLogaritmicaLwAtenuado.toStringAsFixed(presicionDecimales));
  1278. }
  1279. double sumaLogaritmicaEspectroResultante = 0.0;
  1280. if(arrEspectroResultante.length > 0){
  1281. sumaLogaritmicaEspectroResultante = 10 * (_log10(math.pow(10, (arrEspectroResultante["63Hz"]!/10)) + math.pow(10, (arrEspectroResultante["125Hz"]!/10)).toDouble()
  1282. + math.pow(10, (arrEspectroResultante["250Hz"]!/10)) + math.pow(10, (arrEspectroResultante["500Hz"]!/10)).toDouble()
  1283. + math.pow(10, (arrEspectroResultante["1000Hz"]!/10)) + math.pow(10, (arrEspectroResultante["2000Hz"]!/10)).toDouble()
  1284. + math.pow(10, (arrEspectroResultante["4000Hz"]!/10)) + math.pow(10, (arrEspectroResultante["8000Hz"]!/10)).toDouble()
  1285. ));
  1286. sumaLogaritmicaEspectroResultante = double.parse(sumaLogaritmicaEspectroResultante.toStringAsFixed(presicionDecimales));
  1287. }
  1288. double resultadoPresionSonoraAA = sumaLogaritmicaLwAtenuado - (10 * _log10((4 * math.pi) * (math.pow(1.5, 2) / 2)));
  1289. resultadoPresionSonoraAA = double.parse(resultadoPresionSonoraAA.toStringAsFixed(presicionDecimales));
  1290. double resultadoPresionSonoraBB = sumaLogaritmicaEspectroResultante - (10 * _log10((4 * math.pi) * (math.pow(1.5, 2) / 2)));
  1291. resultadoPresionSonoraBB = double.parse(resultadoPresionSonoraBB.toStringAsFixed(presicionDecimales));
  1292. final Map<String, double> fArrLwFinal = {};
  1293. arrLwFinal.forEach((key, value) {
  1294. double val = value;
  1295. if(value == double.negativeInfinity || value == double.infinity){
  1296. val = 0.0;
  1297. }
  1298. fArrLwFinal[key] = val;
  1299. });
  1300. if(sumaLogaritmicaLwFinal == double.negativeInfinity || sumaLogaritmicaLwFinal == double.infinity){
  1301. sumaLogaritmicaLwFinal = 0.0;
  1302. }
  1303. final Map<String, double> fArrLwA = {};
  1304. arrLwA.forEach((key, value) {
  1305. double val = value;
  1306. if(value == double.negativeInfinity || value == double.infinity){
  1307. val = 0.0;
  1308. }
  1309. fArrLwA[key] = val;
  1310. });
  1311. if(sumaLogaritmicaLwA == double.negativeInfinity || sumaLogaritmicaLwA == double.infinity){
  1312. sumaLogaritmicaLwA = 0.0;
  1313. }
  1314. Navigator.push(context, MaterialPageRoute(
  1315. builder: (context) => ResultadoPage(
  1316. frecuencias: arrFrecuencias,
  1317. arrLwFinal: fArrLwFinal,
  1318. sumaLogaritmicaLwFinal: sumaLogaritmicaLwFinal,
  1319. arrLwA: fArrLwA,
  1320. sumaLogaritmicaLwA: sumaLogaritmicaLwA,
  1321. presionSonora: resultadoPresionSonora,
  1322. arrSumaLog: arrSumaLog,
  1323. sumaLogaritmicaLwFinalVa: sumaLogaritmicaLwAtenuado,
  1324. arrEspectroResultante: arrEspectroResultante,
  1325. sumaLogaritmicaLwAVa: sumaLogaritmicaEspectroResultante,
  1326. presionSonoraVa: resultadoPresionSonoraAA,
  1327. arrAtenuador: arrAtenuador,
  1328. arrDatosEntrada: arrDatosDeEntrada,
  1329. arrConversiones: arrConversiones,
  1330. ),
  1331. ));
  1332. }
  1333. String _getKey(Map<String, double> map, double needle){
  1334. List values = map.values.toList();
  1335. List keys = map.keys.toList();
  1336. int index = values.indexOf(needle);
  1337. return keys[index];
  1338. }
  1339. Map<String, double> _sortMapItems(Map<String, double> toSort){
  1340. Map<String, double> tmp = Map<String, double>();
  1341. List values = toSort.values.toList();
  1342. List keys = toSort.keys.toList();
  1343. values.sort();
  1344. values.reversed;
  1345. values.forEach((value) {
  1346. keys.forEach((key) {
  1347. if(!tmp.containsKey(key) && toSort[key] == value){
  1348. tmp[key] = value;
  1349. }
  1350. });
  1351. });
  1352. return tmp;
  1353. }
  1354. double _precisarDecimales(int presicion, double num){
  1355. return double.parse(num.toStringAsFixed(presicion));
  1356. }
  1357. void _errorCarga(String error){
  1358. showDialog(
  1359. context: context,
  1360. barrierDismissible: true,
  1361. builder: (context) => AlertDialog(
  1362. title: Text(
  1363. '¡ERROR!',
  1364. ),
  1365. content: Text(
  1366. 'Se produjo el siguiente error: <<$error>>.'
  1367. ),
  1368. actions: [
  1369. TextButton(
  1370. child: Text(
  1371. 'Regresar al inicio'
  1372. ),
  1373. onPressed: () => Navigator.pop(context),
  1374. )
  1375. ],
  1376. )
  1377. );
  1378. }
  1379. }