|
- import 'package:farm_tpf/utils/validators.dart';
- import 'package:flutter/material.dart';
-
- class FieldDateWidget extends StatelessWidget {
- final String hint;
- final String value;
- final Function onPressed;
- final String invalidMessage;
- FieldDateWidget(
- {@required this.hint,
- this.value,
- @required this.onPressed,
- this.invalidMessage});
- @override
- Widget build(BuildContext context) {
- return SizedBox(
- width: double.infinity,
- height: Validators.stringNotNullOrEmpty(invalidMessage) ? 85 : 65,
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Text(
- hint ?? '',
- style: TextStyle(
- color: Validators.stringNotNullOrEmpty(invalidMessage)
- ? Colors.red
- : Colors.black54,
- fontSize: 13.0),
- ),
- SizedBox(
- width: double.infinity,
- height: 44,
- child: FlatButton(
- padding: EdgeInsets.only(
- top: 0.0, right: 0.0, bottom: 0.0, left: 0.0),
- onPressed: onPressed,
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Container(
- padding: EdgeInsets.only(
- top: 0.0, right: 0.0, bottom: 10.5, left: 0.0),
- decoration: BoxDecoration(
- border: Border(
- bottom: BorderSide(
- width: 0.5,
- color: Validators.stringNotNullOrEmpty(
- invalidMessage)
- ? Colors.red
- : Colors.black54)),
- ),
- child: Row(
- children: [
- Expanded(
- child: Text(value ?? hint,
- style: TextStyle(
- fontSize: 16.0,
- color: Colors.black45))),
- Icon(
- Icons.date_range,
- color: Colors.grey,
- ),
- ],
- ))
- ],
- )),
- ),
- Validators.stringNotNullOrEmpty(invalidMessage)
- ? Text(
- invalidMessage ?? '',
- style: TextStyle(
- fontSize: 12.0,
- color: Colors.red,
- fontWeight: FontWeight.normal),
- textAlign: TextAlign.left,
- )
- : SizedBox(),
- ],
- ),
- );
- }
- }
|