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.

85 lines
2.9KB

  1. import 'package:farm_tpf/utils/validators.dart';
  2. import 'package:flutter/material.dart';
  3. class DropdownSupplyWidget extends StatelessWidget {
  4. final String condition;
  5. final String hint;
  6. final String value;
  7. final Function onPressed;
  8. final String invalidMessage;
  9. DropdownSupplyWidget(
  10. {@required this.hint,
  11. this.value,
  12. @required this.condition,
  13. @required this.onPressed,
  14. this.invalidMessage});
  15. @override
  16. Widget build(BuildContext context) {
  17. return SizedBox(
  18. width: double.infinity,
  19. height: Validators.stringNotNullOrEmpty(invalidMessage) ? 85 : 65,
  20. child: Column(
  21. crossAxisAlignment: CrossAxisAlignment.start,
  22. children: [
  23. Text(
  24. hint ?? '',
  25. style: TextStyle(
  26. color: Validators.stringNotNullOrEmpty(invalidMessage)
  27. ? Colors.red
  28. : Colors.black54,
  29. fontSize: 13.0),
  30. ),
  31. SizedBox(
  32. width: double.infinity,
  33. height: 44,
  34. child: FlatButton(
  35. padding: EdgeInsets.only(
  36. top: 0.0, right: 0.0, bottom: 0.0, left: 0.0),
  37. onPressed: onPressed,
  38. child: Column(
  39. crossAxisAlignment: CrossAxisAlignment.start,
  40. children: [
  41. Container(
  42. padding: EdgeInsets.only(
  43. top: 0.0, right: 0.0, bottom: 10.5, left: 0.0),
  44. decoration: BoxDecoration(
  45. border: Border(
  46. bottom: BorderSide(
  47. width: 0.5,
  48. color: Validators.stringNotNullOrEmpty(
  49. invalidMessage)
  50. ? Colors.red
  51. : Colors.black54)),
  52. ),
  53. child: Row(
  54. children: [
  55. Expanded(
  56. child: Text(value ?? hint,
  57. style: TextStyle(
  58. fontSize: 16.0,
  59. color: Colors.black45))),
  60. Icon(
  61. Icons.arrow_drop_down,
  62. color: Colors.grey,
  63. ),
  64. ],
  65. ))
  66. ],
  67. )),
  68. ),
  69. Validators.stringNotNullOrEmpty(invalidMessage)
  70. ? Text(
  71. invalidMessage ?? '',
  72. style: TextStyle(
  73. fontSize: 12.0,
  74. color: Colors.red,
  75. fontWeight: FontWeight.normal),
  76. textAlign: TextAlign.left,
  77. )
  78. : SizedBox(),
  79. ],
  80. ),
  81. );
  82. }
  83. }