You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

734 lines
33KB

  1. import 'package:farm_tpf/custom_model/Device.dart';
  2. import 'package:farm_tpf/custom_model/SuppliesUsing.dart';
  3. import 'package:farm_tpf/custom_model/Supply.dart';
  4. import 'package:farm_tpf/presentation/custom_widgets/WidgetErrorTextField.dart';
  5. import 'package:farm_tpf/presentation/custom_widgets/widget_text_form_field.dart';
  6. import 'package:farm_tpf/presentation/custom_widgets/widget_utils.dart';
  7. import 'package:farm_tpf/presentation/screens/actions/controller/ChangeDevice.dart';
  8. import 'package:farm_tpf/presentation/screens/actions/controller/ChangeFieldInForm.dart';
  9. import 'package:farm_tpf/presentation/screens/actions/controller/ChangeFormButton.dart';
  10. import 'package:farm_tpf/presentation/screens/actions/controller/ChangeSupplyUsing.dart';
  11. import 'package:farm_tpf/presentation/screens/actions/controller/ChangeUnit.dart';
  12. import 'package:farm_tpf/presentation/screens/actions/resource_device_activity/sc_device_activity.dart';
  13. import 'package:farm_tpf/presentation/screens/actions/state_management_helper/change_supply.dart';
  14. import 'package:farm_tpf/presentation/screens/resources/sc_resource_helper.dart';
  15. import 'package:farm_tpf/utils/const_string.dart';
  16. import 'package:farm_tpf/utils/const_style.dart';
  17. import 'package:farm_tpf/utils/validators.dart';
  18. import 'package:flutter/material.dart';
  19. import 'package:get/get.dart';
  20. import 'package:farm_tpf/utils/formatter.dart';
  21. import 'util_action.dart';
  22. class SupplyWidget extends StatefulWidget {
  23. final List<SuppliesUsing> currentItems;
  24. final Function(List<SuppliesUsing> supplyChanges) onChangeSupplies;
  25. final String urlSupply;
  26. final String supplyGroup;
  27. SupplyWidget({
  28. required this.currentItems,
  29. required this.onChangeSupplies,
  30. required this.urlSupply,
  31. required this.supplyGroup,
  32. });
  33. @override
  34. _SupplyWidgetState createState() => _SupplyWidgetState();
  35. }
  36. class _SupplyWidgetState extends State<SupplyWidget> {
  37. final _dosageController = TextEditingController();
  38. final _quantityController = TextEditingController();
  39. final _howToUseController = TextEditingController();
  40. final changeSelectedSupply = Get.put(ChangeSupply());
  41. final changeSupplyUsing = Get.put(ChangeSupplyUsing());
  42. final changeUnit = Get.put(ChangeUnit());
  43. final changeButton = Get.put(ChangeButtonInForm());
  44. final changeSelectedDevice = Get.put(ChangeDevice());
  45. final changeFormField = Get.put(ChangeFieldFormSupply());
  46. GlobalKey<FormState> _formSupplyKey = GlobalKey();
  47. @override
  48. void initState() {
  49. super.initState();
  50. changeSelectedSupply.initValue();
  51. changeSelectedDevice.initValue();
  52. changeSupplyUsing.init(widget.currentItems);
  53. changeUnit.initValue();
  54. changeButton.resetValue();
  55. changeFormField.init();
  56. }
  57. Widget _buildListSupply() {
  58. return GetBuilder<ChangeSupplyUsing>(
  59. init: changeSupplyUsing,
  60. builder: (value) {
  61. widget.onChangeSupplies(value.currentItems ?? []);
  62. if (value.currentItems!.isEmpty) {
  63. return Container();
  64. } else {
  65. return Container(
  66. height: 120,
  67. child: ListView.builder(
  68. physics: ClampingScrollPhysics(),
  69. scrollDirection: Axis.horizontal,
  70. shrinkWrap: true,
  71. itemCount: value.currentItems?.length,
  72. itemBuilder: (context, index) {
  73. return GestureDetector(
  74. onTap: () {
  75. print("edit");
  76. changeSupplyUsing.changeIndexEdit(index);
  77. changeButton.updateToEdit(true);
  78. var editedSupplyUsing =
  79. value.currentItems?[index] ?? SuppliesUsing();
  80. var editedSupply = Supply()
  81. ..id = editedSupplyUsing.tbSuppliesInWarehouseId
  82. ..tbSuppliesName = editedSupplyUsing.supplyName
  83. ..unit = editedSupplyUsing.supplyUnit;
  84. changeSelectedSupply.change(editedSupply);
  85. var editedDevice = Device()
  86. ..id = editedSupplyUsing.tbEquipmentOfCustomerId
  87. ..name = editedSupplyUsing.equipmentName;
  88. changeSelectedDevice.change(editedDevice);
  89. changeUnit.updateListByUnitName(
  90. editedSupplyUsing.supplyUnit ?? '');
  91. changeUnit.updateSelected(
  92. editedSupplyUsing.supplyUnit ?? '');
  93. _dosageController.text =
  94. editedSupplyUsing.dosage ?? '';
  95. _howToUseController.text =
  96. editedSupplyUsing.howToUse ?? '';
  97. _quantityController.text = editedSupplyUsing
  98. .quantity
  99. ?.formatNumtoStringDecimal() ??
  100. '0';
  101. },
  102. child: Card(
  103. child: Stack(
  104. alignment: Alignment.bottomCenter,
  105. children: <Widget>[
  106. Positioned(
  107. child: ClipRRect(
  108. borderRadius: BorderRadius.circular(8),
  109. child: Container(
  110. padding: EdgeInsets.all(4),
  111. width: 150,
  112. child: Column(
  113. crossAxisAlignment:
  114. CrossAxisAlignment.center,
  115. mainAxisAlignment: MainAxisAlignment.center,
  116. children: [
  117. SizedBox(
  118. height: 12.0,
  119. ),
  120. Flexible(
  121. child: Text(
  122. value.currentItems?[index]
  123. .supplyName ??
  124. "",
  125. overflow: TextOverflow.ellipsis,
  126. maxLines: 1),
  127. ),
  128. Validators.stringNotNullOrEmpty(value
  129. .currentItems?[index]
  130. .dosage ??
  131. '')
  132. ? Flexible(
  133. child: Text(
  134. "${value.currentItems?[index].dosage ?? ""}"))
  135. : SizedBox(),
  136. Validators.stringNotNullOrEmpty(value
  137. .currentItems?[index].quantity
  138. ?.formatNumtoStringDecimal() ??
  139. '0')
  140. ? Flexible(
  141. child: Text(
  142. "${value.currentItems?[index].quantity?.formatNumtoStringDecimal() ?? ""} ${value.currentItems?[index].supplyUnit ?? ""}"))
  143. : SizedBox(),
  144. Validators.stringNotNullOrEmpty(value
  145. .currentItems?[index]
  146. .equipmentName ??
  147. '')
  148. ? Flexible(
  149. child: Text(
  150. "${value.currentItems?[index].equipmentName ?? ""}"))
  151. : SizedBox(),
  152. Validators.stringNotNullOrEmpty(value
  153. .currentItems?[index]
  154. .howToUse ??
  155. '')
  156. ? Flexible(
  157. child: Text(
  158. "${value.currentItems?[index].howToUse ?? ""}"))
  159. : SizedBox(),
  160. ],
  161. ),
  162. ),
  163. )),
  164. Positioned(
  165. top: -10,
  166. right: -10,
  167. child: IconButton(
  168. icon: Icon(
  169. Icons.cancel,
  170. color: Colors.redAccent,
  171. ),
  172. onPressed: () {
  173. changeSupplyUsing.deleteSupply(index);
  174. }),
  175. )
  176. ],
  177. )));
  178. }));
  179. }
  180. });
  181. }
  182. Widget _btnSelectSubstrates() {
  183. return GetBuilder<ChangeSupply>(
  184. init: changeSelectedSupply,
  185. builder: (data) {
  186. return TextButton(
  187. onPressed: () {
  188. var currentIndexEdit = changeSupplyUsing.currentIndex;
  189. Navigator.of(context)
  190. .push(MaterialPageRoute(
  191. builder: (_) => ResourceHelperScreen(
  192. titleName: widget.supplyGroup,
  193. urlSupply: widget.urlSupply,
  194. selectedId:
  195. changeSelectedSupply.selectedSupplyId ?? -1,
  196. currentItems:
  197. changeSupplyUsing.currentItems ?? [],
  198. currentEditId: ((currentIndexEdit ?? 0) >= 0)
  199. ? changeSupplyUsing
  200. .currentItems![currentIndexEdit!]
  201. .tbSuppliesInWarehouseId ??
  202. -1
  203. : -1,
  204. ),
  205. fullscreenDialog: false))
  206. .then((value) {
  207. if (value != null) {
  208. var result = value as Supply;
  209. changeSelectedSupply.change(result);
  210. changeUnit.updateListByUnitName(result.unit ?? '');
  211. changeFormField.change(true);
  212. }
  213. });
  214. },
  215. child: GetBuilder<ChangeSupply>(
  216. init: changeSelectedSupply,
  217. builder: (_) {
  218. var isValid = changeSelectedSupply.isValid;
  219. return Column(
  220. crossAxisAlignment: CrossAxisAlignment.start,
  221. children: [
  222. Container(
  223. padding: EdgeInsets.only(
  224. top: 0.0, right: 0.0, bottom: 10.5, left: 0.0),
  225. decoration: BoxDecoration(
  226. border: Border(
  227. bottom: BorderSide(
  228. width: 1,
  229. color: (isValid ?? false)
  230. ? Colors.grey
  231. : Colors.red)),
  232. ),
  233. child: Column(
  234. crossAxisAlignment: CrossAxisAlignment.start,
  235. children: [
  236. Validators.stringNotNullOrEmpty(
  237. changeSelectedSupply
  238. .selectedSupplyName ??
  239. '')
  240. ? Text(
  241. 'Tên thương mại *',
  242. style: TextStyle(
  243. fontSize: 13,
  244. fontWeight: FontWeight.normal,
  245. color: (isValid ?? false)
  246. ? Colors.black54
  247. : Colors.red[600]),
  248. )
  249. : Text(
  250. '',
  251. style: TextStyle(
  252. fontSize: 13,
  253. fontWeight: FontWeight.normal,
  254. color: (isValid ?? false)
  255. ? Colors.black54
  256. : Colors.red[600]),
  257. ),
  258. Row(
  259. children: [
  260. Expanded(
  261. child: Validators.stringNotNullOrEmpty(
  262. changeSelectedSupply
  263. .selectedSupplyName ??
  264. '')
  265. ? Text(
  266. changeSelectedSupply
  267. .selectedSupplyName ??
  268. '',
  269. style: TextStyle(
  270. fontSize: 14.0,
  271. color: Colors.black87))
  272. : Text("Tên thương mại*",
  273. style: TextStyle(
  274. fontSize: 14.0,
  275. color: Colors.black54)),
  276. ),
  277. Icon(
  278. Icons.arrow_drop_down,
  279. color: Colors.grey,
  280. ),
  281. ],
  282. )
  283. ],
  284. )),
  285. (isValid ?? false) ? SizedBox() : WidgetErrorTextField()
  286. ],
  287. );
  288. }));
  289. });
  290. }
  291. Widget _btnSelectDevice() {
  292. return GetBuilder<ChangeDevice>(
  293. init: changeSelectedDevice,
  294. builder: (data) {
  295. return TextButton(
  296. onPressed: () {
  297. Navigator.of(context)
  298. .push(MaterialPageRoute(
  299. builder: (_) => ListDeviceActivity(
  300. selectedId:
  301. changeSelectedDevice.selectedDeviceId ?? -1),
  302. fullscreenDialog: false))
  303. .then((value) {
  304. if (value != null) {
  305. var result = value as Device;
  306. changeSelectedDevice.change(result);
  307. changeFormField.change(true);
  308. }
  309. });
  310. },
  311. child: Container(
  312. padding: EdgeInsets.only(
  313. top: 0.0, right: 0.0, bottom: 10.5, left: 0.0),
  314. decoration: BoxDecoration(
  315. border: kBorderTextField,
  316. ),
  317. child: Column(
  318. crossAxisAlignment: CrossAxisAlignment.start,
  319. children: [
  320. Validators.stringNotNullOrEmpty(
  321. changeSelectedDevice.selectedDeviceName ?? '')
  322. ? Text(
  323. 'Thiết bị',
  324. style: TextStyle(
  325. fontSize: 13,
  326. fontWeight: FontWeight.normal,
  327. color: Colors.black54),
  328. )
  329. : Text(
  330. '',
  331. style: TextStyle(
  332. fontSize: 13,
  333. fontWeight: FontWeight.normal,
  334. color: Colors.black54),
  335. ),
  336. Row(
  337. children: [
  338. GetBuilder<ChangeSupply>(
  339. init: changeSelectedSupply,
  340. builder: (_) => Expanded(
  341. child: Validators.stringNotNullOrEmpty(
  342. changeSelectedDevice
  343. .selectedDeviceName ??
  344. '')
  345. ? Text(
  346. changeSelectedDevice
  347. .selectedDeviceName ??
  348. '',
  349. style: TextStyle(
  350. fontSize: 14.0,
  351. color: Colors.black87))
  352. : Text("Thiết bị",
  353. style: TextStyle(
  354. fontSize: 14.0,
  355. color: Colors.black54)),
  356. )),
  357. Icon(
  358. Icons.arrow_drop_down,
  359. color: Colors.grey,
  360. ),
  361. ],
  362. ),
  363. ],
  364. )));
  365. });
  366. }
  367. Widget _dropdownUnitTypes() {
  368. return GetBuilder<ChangeUnit>(
  369. init: changeUnit,
  370. builder: (data) {
  371. return DropdownButtonFormField<String>(
  372. itemHeight: 50,
  373. value: !Validators.stringNotNullOrEmpty(data.selectedUnit ?? '')
  374. ? null
  375. : data.selectedUnit,
  376. items: data.currentUnits!
  377. .map((label) => DropdownMenuItem(
  378. child: Text(label),
  379. value: label,
  380. ))
  381. .toList(),
  382. onChanged: (value) {
  383. var currentQuantity = _quantityController.text;
  384. num assignValue = currentQuantity.parseDoubleThousand();
  385. if (assignValue != null) {
  386. var oldSelected = data.selectedUnit;
  387. if (oldSelected == value) {
  388. } else {
  389. assignValue = UtilAction.convertUnit(
  390. inputValue: assignValue,
  391. oldUnit: oldSelected ?? '',
  392. newUnit: value ?? '',
  393. );
  394. }
  395. _quantityController.text =
  396. assignValue.formatNumtoStringDecimal();
  397. }
  398. changeUnit.updateSelected(value ?? '');
  399. },
  400. );
  401. });
  402. }
  403. _quantityField() {
  404. return WidgetTextFormFieldNumber(
  405. hintValue: "Tổng lượng sử dụng *",
  406. labelText: "Tổng lượng sử dụng *",
  407. textController: _quantityController,
  408. validator: (String? value) {
  409. return Validators.validateNotNullOrEmpty(
  410. value ?? '', label_validate_input_empty);
  411. },
  412. onChanged: (value) {
  413. if (!Validators.stringNotNullOrEmpty(value ?? '') &&
  414. !Validators.stringNotNullOrEmpty(_howToUseController.text) &&
  415. !Validators.stringNotNullOrEmpty(_dosageController.text) &&
  416. (Get.find<ChangeSupply>().selectedSupplyId ?? -1) <= 0 &&
  417. (changeSelectedDevice.selectedDeviceId ?? -1) <= 0) {
  418. changeFormField.change(false);
  419. } else {
  420. changeFormField.change(true);
  421. }
  422. },
  423. );
  424. }
  425. _buttonInForm() {
  426. return GetBuilder<ChangeButtonInForm>(
  427. init: changeButton,
  428. builder: (_) {
  429. return Row(
  430. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  431. children: [
  432. _.isEdit ?? false
  433. ? TextButton(
  434. child: Text("Huỷ"),
  435. onPressed: () {
  436. changeButton.resetValue();
  437. _resetForm();
  438. _hidenKeyboard(context);
  439. })
  440. : SizedBox(),
  441. _.isEdit ?? false
  442. ? Expanded(
  443. child: TextButton(
  444. onPressed: () {
  445. if (_formSupplyKey.currentState!.validate()) {
  446. _formSupplyKey.currentState!.save();
  447. if ((changeSelectedSupply.selectedSupplyId ??
  448. -1) <=
  449. 0) {
  450. changeSelectedSupply.changeValid(false);
  451. } else {
  452. changeSelectedSupply.changeValid(true);
  453. }
  454. var currentSupply =
  455. changeSelectedSupply.currentSupply;
  456. var currentDevice =
  457. changeSelectedDevice.currentDevice;
  458. var currentQuantity = _quantityController.text
  459. .parseDoubleThousand();
  460. if (currentSupply?.id != null &&
  461. (currentQuantity ?? 0) > 0) {
  462. var quantityWithCurrentSupplyUnit =
  463. UtilAction.convertUnit(
  464. inputValue: currentQuantity,
  465. oldUnit: changeUnit.selectedUnit ?? '',
  466. newUnit: changeSelectedSupply
  467. .currentSupply?.unit ??
  468. '',
  469. );
  470. SuppliesUsing newSup = SuppliesUsing()
  471. ..dosage = _dosageController.text
  472. ..howToUse = _howToUseController.text
  473. ..quantity = quantityWithCurrentSupplyUnit
  474. ..tbSuppliesInWarehouseId = currentSupply?.id
  475. ..suppliesInWarehouseId = currentSupply?.id
  476. ..supplyName = currentSupply?.tbSuppliesName
  477. ..tbEquipmentOfCustomerId =
  478. currentDevice?.id ?? -1
  479. ..equipmentOfCustomerId =
  480. currentDevice?.id ?? -1
  481. ..equipmentName = currentDevice?.name ?? ''
  482. ..supplyUnit = currentSupply?.unit
  483. ..unit = currentSupply?.unit;
  484. changeSupplyUsing.editSupply(
  485. changeSupplyUsing.currentIndex ?? -1,
  486. newSup);
  487. _resetForm();
  488. _hidenKeyboard(context);
  489. } else if (currentSupply?.id == null ||
  490. ((currentQuantity ?? 0) <= 0)) {
  491. Utils.showSnackBarWarning(
  492. message:
  493. "Vui lòng nhập vật tư và số lượng");
  494. }
  495. } else {
  496. Utils.showSnackBarWarning(
  497. message: "Vui lòng nhập vật tư và số lượng");
  498. if ((changeSelectedSupply.selectedSupplyId ??
  499. -1) <=
  500. 0) {
  501. changeSelectedSupply.changeValid(false);
  502. } else {
  503. changeSelectedSupply.changeValid(true);
  504. }
  505. }
  506. },
  507. child: Text(
  508. "Sửa ${widget.supplyGroup}",
  509. style: TextStyle(color: Colors.blue),
  510. )),
  511. )
  512. : Expanded(
  513. child: TextButton(
  514. onPressed: () {
  515. if (_formSupplyKey.currentState!.validate()) {
  516. _formSupplyKey.currentState!.save();
  517. if ((changeSelectedSupply.selectedSupplyId ??
  518. -1) <=
  519. 0) {
  520. changeSelectedSupply.changeValid(false);
  521. } else {
  522. changeSelectedSupply.changeValid(true);
  523. }
  524. var currentSupply =
  525. changeSelectedSupply.currentSupply;
  526. var currentDevice =
  527. changeSelectedDevice.currentDevice;
  528. var currentQuantity = _quantityController.text
  529. .parseDoubleThousand();
  530. if (currentSupply?.id != null &&
  531. (currentQuantity ?? 0) > 0) {
  532. var quantityWithCurrentSupplyUnit =
  533. UtilAction.convertUnit(
  534. inputValue: currentQuantity,
  535. oldUnit: changeUnit.selectedUnit ?? '',
  536. newUnit: changeSelectedSupply
  537. .currentSupply?.unit ??
  538. '',
  539. );
  540. SuppliesUsing newSup = SuppliesUsing()
  541. ..dosage = _dosageController.text
  542. ..howToUse = _howToUseController.text
  543. ..quantity = quantityWithCurrentSupplyUnit
  544. ..tbSuppliesInWarehouseId = currentSupply?.id
  545. ..suppliesInWarehouseId = currentSupply?.id
  546. ..supplyName = currentSupply?.tbSuppliesName
  547. ..supplyUnit = currentSupply?.unit
  548. ..tbEquipmentOfCustomerId =
  549. currentDevice?.id ?? -1
  550. ..equipmentOfCustomerId =
  551. currentDevice?.id ?? -1
  552. ..equipmentName = currentDevice?.name
  553. ..unit = currentSupply?.unit;
  554. changeSupplyUsing.addSupply(newSup);
  555. _resetForm();
  556. _hidenKeyboard(context);
  557. } else if (currentSupply?.id == null ||
  558. ((currentQuantity ?? 0) <= 0)) {
  559. Utils.showSnackBarWarning(
  560. message:
  561. "Vui lòng nhập vật tư và số lượng");
  562. }
  563. } else {
  564. Utils.showSnackBarWarning(
  565. message: "Vui lòng nhập vật tư và số lượng");
  566. if ((changeSelectedSupply.selectedSupplyId ??
  567. -1) <=
  568. 0) {
  569. changeSelectedSupply.changeValid(false);
  570. } else {
  571. changeSelectedSupply.changeValid(true);
  572. }
  573. //
  574. }
  575. },
  576. child: Text(
  577. "+ Thêm ${widget.supplyGroup}",
  578. style: TextStyle(color: Colors.blue),
  579. )),
  580. )
  581. ],
  582. );
  583. });
  584. }
  585. Widget _formEdit() {
  586. return Form(
  587. key: _formSupplyKey,
  588. child: Column(
  589. children: [
  590. Container(
  591. padding: EdgeInsets.all(8.0),
  592. margin: EdgeInsets.all(8.0),
  593. decoration: BoxDecoration(
  594. shape: BoxShape.rectangle,
  595. borderRadius: BorderRadius.circular(10),
  596. color: Colors.white,
  597. border: Border.all(color: Colors.grey),
  598. ),
  599. child: Column(
  600. children: [
  601. _btnSelectSubstrates(),
  602. TextFormField(
  603. keyboardType: TextInputType.text,
  604. controller: _dosageController,
  605. decoration: InputDecoration(labelText: "Liều lượng sử dụng"),
  606. onSaved: (newValue) {},
  607. onChanged: (value) {
  608. if (!Validators.stringNotNullOrEmpty(
  609. _quantityController.text) &&
  610. !Validators.stringNotNullOrEmpty(
  611. _howToUseController.text) &&
  612. !Validators.stringNotNullOrEmpty(value) &&
  613. (Get.find<ChangeSupply>().selectedSupplyId ?? -1) <=
  614. 0 &&
  615. (changeSelectedDevice.selectedDeviceId ?? -1) <= 0) {
  616. changeFormField.change(false);
  617. } else {
  618. changeFormField.change(true);
  619. }
  620. },
  621. ),
  622. Row(
  623. mainAxisSize: MainAxisSize.min,
  624. mainAxisAlignment: MainAxisAlignment.spaceEvenly,
  625. crossAxisAlignment: CrossAxisAlignment.center,
  626. children: [
  627. Expanded(
  628. flex: 2,
  629. child: Container(
  630. height: 70,
  631. child: _quantityField(),
  632. ),
  633. ),
  634. SizedBox(
  635. width: 16.0,
  636. ),
  637. Expanded(
  638. flex: 1,
  639. child: Align(
  640. alignment: Alignment.bottomCenter,
  641. child: _dropdownUnitTypes(),
  642. )),
  643. ]),
  644. _btnSelectDevice(),
  645. TextFormField(
  646. keyboardType: TextInputType.text,
  647. controller: _howToUseController,
  648. decoration: InputDecoration(labelText: "Phương pháp sử dụng"),
  649. onSaved: (newValue) {},
  650. onChanged: (value) {
  651. if (!Validators.stringNotNullOrEmpty(
  652. _quantityController.text) &&
  653. !Validators.stringNotNullOrEmpty(value) &&
  654. !Validators.stringNotNullOrEmpty(
  655. _dosageController.text) &&
  656. (Get.find<ChangeSupply>().selectedSupplyId ?? -1) <=
  657. 0 &&
  658. (changeSelectedDevice.selectedDeviceId ?? -1) <= 0) {
  659. changeFormField.change(false);
  660. } else {
  661. changeFormField.change(true);
  662. }
  663. },
  664. ),
  665. ],
  666. ),
  667. ),
  668. _buttonInForm()
  669. ],
  670. ),
  671. );
  672. }
  673. _resetForm() {
  674. changeSupplyUsing.changeIndexEdit(-1);
  675. changeButton.resetValue();
  676. _dosageController.text = "";
  677. _howToUseController.text = "";
  678. _quantityController.text = "";
  679. changeUnit.initValue();
  680. changeSelectedSupply.initValue();
  681. changeSelectedDevice.initValue();
  682. changeFormField.change(false);
  683. }
  684. _hidenKeyboard(BuildContext context) {
  685. FocusScopeNode currentFocus = FocusScope.of(context);
  686. if (!currentFocus.hasPrimaryFocus) {
  687. currentFocus.unfocus();
  688. }
  689. }
  690. @override
  691. Widget build(BuildContext context) {
  692. return Column(
  693. children: [
  694. Padding(
  695. padding: const EdgeInsets.all(8.0),
  696. child: Align(
  697. alignment: Alignment.centerLeft,
  698. child: Text(
  699. widget.supplyGroup,
  700. style: TextStyle(color: Colors.black54, fontSize: 14),
  701. ),
  702. ),
  703. ),
  704. _buildListSupply(),
  705. SizedBox(
  706. height: 8.0,
  707. ),
  708. _formEdit(),
  709. SizedBox(
  710. height: 8.0,
  711. ),
  712. ],
  713. );
  714. }
  715. }