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.

83 lines
2.9KB

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