Browse Source

fix validate form Bug #7349

master
daivph 5 years ago
parent
commit
f62e0b0ac2
11 changed files with 15 additions and 108 deletions
  1. +1
    -19
      lib/presentation/screens/actions/crop_status/sc_edit_action_crop_status.dart
  2. +2
    -5
      lib/presentation/screens/actions/disease/sc_edit_action_disease.dart
  3. +1
    -1
      lib/presentation/screens/actions/end/sc_edit_action_end.dart
  4. +1
    -19
      lib/presentation/screens/actions/environment_update/sc_edit_action_environment_update.dart
  5. +1
    -13
      lib/presentation/screens/actions/harvest/sc_edit_action_harvest.dart
  6. +1
    -10
      lib/presentation/screens/actions/nursery/sc_edit_action_nursery.dart
  7. +2
    -2
      lib/presentation/screens/actions/other/sc_edit_action_other.dart
  8. +2
    -14
      lib/presentation/screens/actions/packing/sc_edit_action_packing.dart
  9. +1
    -4
      lib/presentation/screens/actions/plant/sc_edit_action_plant.dart
  10. +2
    -17
      lib/presentation/screens/actions/sell/sc_edit_action_sell.dart
  11. +1
    -4
      lib/presentation/screens/actions/use_water/sc_edit_action_user_water.dart

+ 1
- 19
lib/presentation/screens/actions/crop_status/sc_edit_action_crop_status.dart View File

], ],
decoration: InputDecoration(labelText: "Tỉ lệ lên cây"), decoration: InputDecoration(labelText: "Tỉ lệ lên cây"),
controller: _cropRateController, controller: _cropRateController,
validator: (String value) {
return Validators.validNumber(value, "Tỉ lệ lên cây");
},
onSaved: (newValue) { onSaved: (newValue) {
_cropStatus.cropRate = newValue; _cropStatus.cropRate = newValue;
}, },
], ],
decoration: InputDecoration(labelText: "Số lượng lên cây"), decoration: InputDecoration(labelText: "Số lượng lên cây"),
controller: _numTreeController, controller: _numTreeController,
validator: (String value) {
return Validators.validNumber(value, "Số lượng lên cây");
},
onSaved: (newValue) { onSaved: (newValue) {
_cropStatus.numberOfTreeToGrow = newValue; _cropStatus.numberOfTreeToGrow = newValue;
}, },
], ],
decoration: InputDecoration(labelText: "Chiều cao cây"), decoration: InputDecoration(labelText: "Chiều cao cây"),
controller: _heightOfTreeController, controller: _heightOfTreeController,
validator: (String value) {
return Validators.validNumber(value, "Chiều cao cây");
},
onSaved: (newValue) { onSaved: (newValue) {
_cropStatus.heightOfTree = newValue; _cropStatus.heightOfTree = newValue;
}, },
], ],
decoration: InputDecoration(labelText: "Số lá"), decoration: InputDecoration(labelText: "Số lá"),
controller: _numberOfLeafController, controller: _numberOfLeafController,
validator: (String value) {
return Validators.validNumber(value, "Số lá");
},
onSaved: (newValue) { onSaved: (newValue) {
_cropStatus.numberOfLeaf = newValue; _cropStatus.numberOfLeaf = newValue;
}, },
], ],
decoration: InputDecoration(labelText: "Kích thước lá"), decoration: InputDecoration(labelText: "Kích thước lá"),
controller: _leafSizeController, controller: _leafSizeController,
validator: (String value) {
return Validators.validNumber(value, "Kích thước lá");
},
onSaved: (newValue) { onSaved: (newValue) {
_cropStatus.leafSize = newValue; _cropStatus.leafSize = newValue;
}, },
], ],
decoration: InputDecoration(labelText: "Dài đốt thân"), decoration: InputDecoration(labelText: "Dài đốt thân"),
controller: _internodeLengthController, controller: _internodeLengthController,
validator: (String value) {
return Validators.validNumber(value, "Dài đốt thân");
},
onSaved: (newValue) { onSaved: (newValue) {
_cropStatus.internodeLength = newValue; _cropStatus.internodeLength = newValue;
}, },
Container( Container(
width: double.infinity, width: double.infinity,
child: Text( child: Text(
"Ngày thực hiện",
"Ngày thực hiện *",
style: TextStyle( style: TextStyle(
color: Colors.black54, fontSize: 13.0), color: Colors.black54, fontSize: 13.0),
), ),

+ 2
- 5
lib/presentation/screens/actions/disease/sc_edit_action_disease.dart View File

Widget _typeOfPestField() { Widget _typeOfPestField() {
return TextFormField( return TextFormField(
keyboardType: TextInputType.text, keyboardType: TextInputType.text,
decoration: InputDecoration(labelText: "Loại dịch hại"),
decoration: InputDecoration(labelText: "Loại dịch hại *"),
controller: _typesOfPestController, controller: _typesOfPestController,
validator: (String value) { validator: (String value) {
return Validators.validateNotNullOrEmpty(value, "Loại dịch hại"); return Validators.validateNotNullOrEmpty(value, "Loại dịch hại");
], ],
decoration: InputDecoration(labelText: "% cây"), decoration: InputDecoration(labelText: "% cây"),
controller: _treePercentController, controller: _treePercentController,
validator: (String value) {
return Validators.validNumber(value, "% cây");
},
onSaved: (newValue) { onSaved: (newValue) {
_disease.treePercent = newValue; _disease.treePercent = newValue;
}, },
Container( Container(
width: double.infinity, width: double.infinity,
child: Text( child: Text(
"Ngày thực hiện",
"Ngày thực hiện *",
style: TextStyle( style: TextStyle(
color: Colors.black54, fontSize: 13.0), color: Colors.black54, fontSize: 13.0),
), ),

+ 1
- 1
lib/presentation/screens/actions/end/sc_edit_action_end.dart View File

Container( Container(
width: double.infinity, width: double.infinity,
child: Text( child: Text(
"Ngày thực hiện",
"Ngày thực hiện *",
style: TextStyle( style: TextStyle(
color: Colors.black54, fontSize: 13.0), color: Colors.black54, fontSize: 13.0),
), ),

+ 1
- 19
lib/presentation/screens/actions/environment_update/sc_edit_action_environment_update.dart View File

], ],
decoration: InputDecoration(labelText: "EC"), decoration: InputDecoration(labelText: "EC"),
controller: _ecController, controller: _ecController,
validator: (String value) {
return Validators.validNumber(value, "EC");
},
onSaved: (newValue) { onSaved: (newValue) {
_environment.ec = newValue; _environment.ec = newValue;
}, },
], ],
decoration: InputDecoration(labelText: "pH"), decoration: InputDecoration(labelText: "pH"),
controller: _phController, controller: _phController,
validator: (String value) {
return Validators.validNumber(value, "pH");
},
onSaved: (newValue) { onSaved: (newValue) {
_environment.pH = newValue; _environment.pH = newValue;
}, },
], ],
decoration: InputDecoration(labelText: "Nhiệt độ dung dịch"), decoration: InputDecoration(labelText: "Nhiệt độ dung dịch"),
controller: _ocddController, controller: _ocddController,
validator: (String value) {
return Validators.validNumber(value, "Nhiệt độ dung dịch");
},
onSaved: (newValue) { onSaved: (newValue) {
_environment.ocdd = newValue; _environment.ocdd = newValue;
}, },
], ],
decoration: InputDecoration(labelText: "Nhiệt độ môi trường"), decoration: InputDecoration(labelText: "Nhiệt độ môi trường"),
controller: _temperatureController, controller: _temperatureController,
validator: (String value) {
return Validators.validNumber(value, "Nhiệt độ môi trường");
},
onSaved: (newValue) { onSaved: (newValue) {
_environment.temperature = newValue; _environment.temperature = newValue;
}, },
], ],
decoration: InputDecoration(labelText: "Độ ẩm"), decoration: InputDecoration(labelText: "Độ ẩm"),
controller: _doController, controller: _doController,
validator: (String value) {
return Validators.validNumber(value, "Độ ẩm");
},
onSaved: (newValue) { onSaved: (newValue) {
_environment.dodo = newValue; _environment.dodo = newValue;
}, },
], ],
decoration: InputDecoration(labelText: "Lưu lượng nước"), decoration: InputDecoration(labelText: "Lưu lượng nước"),
controller: _llnController, controller: _llnController,
validator: (String value) {
return Validators.validNumber(value, "Lưu lượng nước");
},
onSaved: (newValue) { onSaved: (newValue) {
_environment.lln = newValue; _environment.lln = newValue;
}, },
Container( Container(
width: double.infinity, width: double.infinity,
child: Text( child: Text(
"Ngày thực hiện",
"Ngày thực hiện *",
style: TextStyle( style: TextStyle(
color: Colors.black54, fontSize: 13.0), color: Colors.black54, fontSize: 13.0),
), ),

+ 1
- 13
lib/presentation/screens/actions/harvest/sc_edit_action_harvest.dart View File

], ],
decoration: InputDecoration(labelText: "Số lượng/khối lượng loại 1"), decoration: InputDecoration(labelText: "Số lượng/khối lượng loại 1"),
controller: _l1Controller, controller: _l1Controller,
validator: (String value) {
return Validators.validNumber(value, "Số lượng/khối lượng loại 1");
},
onSaved: (newValue) { onSaved: (newValue) {
_harvest.collectedQuantityLv1 = newValue.parseDoubleThousand(); _harvest.collectedQuantityLv1 = newValue.parseDoubleThousand();
}, },
], ],
decoration: InputDecoration(labelText: "Số lượng/khối lượng loại 2"), decoration: InputDecoration(labelText: "Số lượng/khối lượng loại 2"),
controller: _l2Controller, controller: _l2Controller,
validator: (String value) {
return Validators.validNumber(value, "Số lượng/khối lượng loại 2");
},
onSaved: (newValue) { onSaved: (newValue) {
_harvest.collectedQuantityLv2 = newValue.parseDoubleThousand(); _harvest.collectedQuantityLv2 = newValue.parseDoubleThousand();
}, },
], ],
decoration: InputDecoration(labelText: "Số lượng/khối lượng loại 3"), decoration: InputDecoration(labelText: "Số lượng/khối lượng loại 3"),
controller: _l3Controller, controller: _l3Controller,
validator: (String value) {
return Validators.validNumber(value, "Số lượng/khối lượng loại 3");
},
onSaved: (newValue) { onSaved: (newValue) {
_harvest.collectedQuantityLv3 = newValue.parseDoubleThousand(); _harvest.collectedQuantityLv3 = newValue.parseDoubleThousand();
}, },
], ],
decoration: InputDecoration(labelText: "Số lượng/khối lượng loại bỏ"), decoration: InputDecoration(labelText: "Số lượng/khối lượng loại bỏ"),
controller: _removedQuantityController, controller: _removedQuantityController,
validator: (String value) {
return Validators.validNumber(value, "Số lượng/khối lượng loại bỏ");
},
onSaved: (newValue) { onSaved: (newValue) {
_harvest.removedQuantity = newValue.parseDoubleThousand(); _harvest.removedQuantity = newValue.parseDoubleThousand();
}, },
Container( Container(
width: double.infinity, width: double.infinity,
child: Text( child: Text(
"Ngày thực hiện",
"Ngày thực hiện *",
style: TextStyle( style: TextStyle(
color: Colors.black54, fontSize: 13.0), color: Colors.black54, fontSize: 13.0),
), ),

+ 1
- 10
lib/presentation/screens/actions/nursery/sc_edit_action_nursery.dart View File

], ],
decoration: InputDecoration(labelText: "Chiều dài mần"), decoration: InputDecoration(labelText: "Chiều dài mần"),
controller: _seedLengthController, controller: _seedLengthController,
validator: (String value) {
return Validators.validNumber(value, "Chiều dài mần");
},
onSaved: (newValue) { onSaved: (newValue) {
_nursery.seedLength = newValue.parseDoubleThousand(); _nursery.seedLength = newValue.parseDoubleThousand();
}, },
], ],
decoration: InputDecoration(labelText: "Số lượng hạt gieo"), decoration: InputDecoration(labelText: "Số lượng hạt gieo"),
controller: _quantityController, controller: _quantityController,
validator: (String value) {
return Validators.validNumber(value, "Số lượng hạt gieo");
},
onSaved: (newValue) { onSaved: (newValue) {
_nursery.quantity = newValue.parseDoubleThousand(); _nursery.quantity = newValue.parseDoubleThousand();
}, },
], ],
decoration: InputDecoration(labelText: "Thời gian ngâm hạt"), decoration: InputDecoration(labelText: "Thời gian ngâm hạt"),
controller: _seedIncubationTimeController, controller: _seedIncubationTimeController,
validator: (String value) {
return Validators.validNumber(value, "Thời gian ngâm hạt");
},
onSaved: (newValue) { onSaved: (newValue) {
_nursery.seedIncubationTime = newValue.parseDoubleThousand(); _nursery.seedIncubationTime = newValue.parseDoubleThousand();
}, },
Container( Container(
width: double.infinity, width: double.infinity,
child: Text( child: Text(
"Ngày thực hiện",
"Ngày thực hiện *",
style: TextStyle( style: TextStyle(
color: Colors.black54, color: Colors.black54,
fontSize: 13.0), fontSize: 13.0),

+ 2
- 2
lib/presentation/screens/actions/other/sc_edit_action_other.dart View File

if (snapshot.hasData) { if (snapshot.hasData) {
return DropdownButtonFormField<ActionType>( return DropdownButtonFormField<ActionType>(
value: _actionType, value: _actionType,
hint: Text("Hoạt động"),
hint: Text("Hoạt động *"),
onChanged: (ActionType newValue) { onChanged: (ActionType newValue) {
setState(() { setState(() {
_actionType = newValue; _actionType = newValue;
Container( Container(
width: double.infinity, width: double.infinity,
child: Text( child: Text(
"Ngày thực hiện",
"Ngày thực hiện *",
style: TextStyle( style: TextStyle(
color: Colors.black54, fontSize: 13.0), color: Colors.black54, fontSize: 13.0),
), ),

+ 2
- 14
lib/presentation/screens/actions/packing/sc_edit_action_packing.dart View File

if (snapshot.hasData) { if (snapshot.hasData) {
return DropdownButtonFormField<Harvest>( return DropdownButtonFormField<Harvest>(
value: harvestValue, value: harvestValue,
hint: Text("Mã thu hoạch"),
hint: Text("Mã thu hoạch *"),
onChanged: (Harvest newValue) { onChanged: (Harvest newValue) {
setState(() { setState(() {
harvestValue = newValue; harvestValue = newValue;
], ],
decoration: InputDecoration(labelText: "Số lượng/khối lượng loại 1"), decoration: InputDecoration(labelText: "Số lượng/khối lượng loại 1"),
controller: _l1Controller, controller: _l1Controller,
validator: (String value) {
return Validators.validNumber(value, "Số lượng/khối lượng loại 1");
},
onSaved: (newValue) { onSaved: (newValue) {
_packing.quantityLv1 = newValue.parseDoubleThousand(); _packing.quantityLv1 = newValue.parseDoubleThousand();
}, },
], ],
decoration: InputDecoration(labelText: "Số lượng/khối lượng loại 2"), decoration: InputDecoration(labelText: "Số lượng/khối lượng loại 2"),
controller: _l2Controller, controller: _l2Controller,
validator: (String value) {
return Validators.validNumber(value, "Số lượng/khối lượng loại 2");
},
onSaved: (newValue) { onSaved: (newValue) {
_packing.quantityLv2 = newValue.parseDoubleThousand(); _packing.quantityLv2 = newValue.parseDoubleThousand();
}, },
], ],
decoration: InputDecoration(labelText: "Số lượng/khối lượng loại 3"), decoration: InputDecoration(labelText: "Số lượng/khối lượng loại 3"),
controller: _l3Controller, controller: _l3Controller,
validator: (String value) {
return Validators.validNumber(value, "Số lượng/khối lượng loại 3");
},
onSaved: (newValue) { onSaved: (newValue) {
_packing.quantityLv3 = newValue.parseDoubleThousand(); _packing.quantityLv3 = newValue.parseDoubleThousand();
}, },
], ],
decoration: InputDecoration(labelText: "Số lượng/khối lượng loại bỏ"), decoration: InputDecoration(labelText: "Số lượng/khối lượng loại bỏ"),
controller: _removedQuantityController, controller: _removedQuantityController,
validator: (String value) {
return Validators.validNumber(value, "Số lượng/khối lượng loại bỏ");
},
onSaved: (newValue) { onSaved: (newValue) {
_packing.removedQuantity = newValue.parseDoubleThousand(); _packing.removedQuantity = newValue.parseDoubleThousand();
}, },
Container( Container(
width: double.infinity, width: double.infinity,
child: Text( child: Text(
"Ngày thực hiện",
"Ngày thực hiện *",
style: TextStyle( style: TextStyle(
color: Colors.black54, fontSize: 13.0), color: Colors.black54, fontSize: 13.0),
), ),

+ 1
- 4
lib/presentation/screens/actions/plant/sc_edit_action_plant.dart View File

], ],
decoration: InputDecoration(labelText: "Số lượng cây trồng"), decoration: InputDecoration(labelText: "Số lượng cây trồng"),
controller: _quantityController, controller: _quantityController,
validator: (String value) {
return Validators.validNumber(value, "Số lượng cây trồng");
},
onSaved: (newValue) { onSaved: (newValue) {
_plant.quantity = newValue.parseDoubleThousand(); _plant.quantity = newValue.parseDoubleThousand();
}, },
Container( Container(
width: double.infinity, width: double.infinity,
child: Text( child: Text(
"Ngày thực hiện",
"Ngày thực hiện *",
style: TextStyle( style: TextStyle(
color: Colors.black54, color: Colors.black54,
fontSize: 13.0), fontSize: 13.0),

+ 2
- 17
lib/presentation/screens/actions/sell/sc_edit_action_sell.dart View File

if (snapshot.hasData) { if (snapshot.hasData) {
return DropdownButtonFormField<Harvest>( return DropdownButtonFormField<Harvest>(
value: harvestValue, value: harvestValue,
hint: Text("Mã thu hoạch"),
hint: Text("Mã thu hoạch *"),
onChanged: (Harvest newValue) { onChanged: (Harvest newValue) {
setState(() { setState(() {
harvestValue = newValue; harvestValue = newValue;
], ],
decoration: InputDecoration(labelText: "Số lượng/khối lượng loại 1"), decoration: InputDecoration(labelText: "Số lượng/khối lượng loại 1"),
controller: _l1Controller, controller: _l1Controller,
validator: (String value) {
return Validators.validNumber(value, "Số lượng/khối lượng loại 1");
},
onSaved: (newValue) { onSaved: (newValue) {
_sell.quantityLv1 = newValue.parseDoubleThousand(); _sell.quantityLv1 = newValue.parseDoubleThousand();
}, },
], ],
decoration: InputDecoration(labelText: "Số lượng/khối lượng loại 2"), decoration: InputDecoration(labelText: "Số lượng/khối lượng loại 2"),
controller: _l2Controller, controller: _l2Controller,
validator: (String value) {
return Validators.validNumber(value, "Số lượng/khối lượng loại 2");
},
onSaved: (newValue) { onSaved: (newValue) {
_sell.quantityLv2 = newValue.parseDoubleThousand(); _sell.quantityLv2 = newValue.parseDoubleThousand();
}, },
], ],
decoration: InputDecoration(labelText: "Số lượng/khối lượng loại 3"), decoration: InputDecoration(labelText: "Số lượng/khối lượng loại 3"),
controller: _l3Controller, controller: _l3Controller,
validator: (String value) {
return Validators.validNumber(value, "Số lượng/khối lượng loại 3");
},
onSaved: (newValue) { onSaved: (newValue) {
_sell.quantityLv3 = newValue.parseDoubleThousand(); _sell.quantityLv3 = newValue.parseDoubleThousand();
}, },
], ],
decoration: InputDecoration(labelText: "Số lượng/khối lượng loại bỏ"), decoration: InputDecoration(labelText: "Số lượng/khối lượng loại bỏ"),
controller: _removedQuantityController, controller: _removedQuantityController,
validator: (String value) {
return Validators.validNumber(value, "Số lượng/khối lượng loại bỏ");
},
onSaved: (newValue) { onSaved: (newValue) {
_sell.removedQuantity = newValue.parseDoubleThousand(); _sell.removedQuantity = newValue.parseDoubleThousand();
}, },
keyboardType: TextInputType.text, keyboardType: TextInputType.text,
decoration: InputDecoration(labelText: "Khách hàng"), decoration: InputDecoration(labelText: "Khách hàng"),
controller: _buyerController, controller: _buyerController,
validator: (String value) {
return Validators.validateNotNullOrEmpty(value, "Khách hàng");
},
onSaved: (newValue) { onSaved: (newValue) {
_sell.buyer = newValue; _sell.buyer = newValue;
}, },
Container( Container(
width: double.infinity, width: double.infinity,
child: Text( child: Text(
"Ngày thực hiện",
"Ngày thực hiện *",
style: TextStyle( style: TextStyle(
color: Colors.black54, fontSize: 13.0), color: Colors.black54, fontSize: 13.0),
), ),

+ 1
- 4
lib/presentation/screens/actions/use_water/sc_edit_action_user_water.dart View File

], ],
decoration: InputDecoration(labelText: "Thể tích nước sử dụng"), decoration: InputDecoration(labelText: "Thể tích nước sử dụng"),
controller: _amountController, controller: _amountController,
validator: (String value) {
return Validators.validNumber(value, "Thể tích nước sử dụng");
},
onSaved: (newValue) { onSaved: (newValue) {
_useWater.amount = newValue.parseDoubleThousand(); _useWater.amount = newValue.parseDoubleThousand();
}, },
Container( Container(
width: double.infinity, width: double.infinity,
child: Text( child: Text(
"Ngày thực hiện",
"Ngày thực hiện *",
style: TextStyle( style: TextStyle(
color: Colors.black54, fontSize: 13.0), color: Colors.black54, fontSize: 13.0),
), ),

Loading…
Cancel
Save