Browse Source

clean code

smf
daivp 4 years ago
parent
commit
f8230980dc
1 changed files with 24 additions and 28 deletions
  1. +24
    -28
      lib/presentation/custom_widgets/widget_action_field_date.dart

+ 24
- 28
lib/presentation/custom_widgets/widget_action_field_date.dart View File

class _FieldDateWidgetState extends State<FieldDateWidget> { class _FieldDateWidgetState extends State<FieldDateWidget> {
ChangeDateTimePicker controller; ChangeDateTimePicker controller;
final textController = TextEditingController(); final textController = TextEditingController();
var isShowError = false;


@override @override
void initState() { void initState() {
builder: (data) { builder: (data) {
return SizedBox( return SizedBox(
width: double.infinity, width: double.infinity,
height: Validators.stringNotNullOrEmpty(textController.text) &&
validators != null
? 65
: widget.isValidated
? 85
: 85,
height: isShowError() ? 85 : 65,
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Validators.stringNotNullOrEmpty(
data?.selectedDateTime?.displayDateTime_DDMMYYYY_HHmm())
isShowError()
? Text( ? Text(
widget.hint ?? '', widget.hint ?? '',
style: TextStyle(
color: Validators.stringNotNullOrEmpty(
textController.text) &&
validators != null
? Colors.black54
: Colors.red,
fontSize: 13.0),
style: TextStyle(color: Colors.red, fontSize: 13.0),
) )
: Text( : Text(
'', '',
border: Border( border: Border(
bottom: BorderSide( bottom: BorderSide(
width: 0.5, width: 0.5,
color: Validators.stringNotNullOrEmpty(
textController.text) &&
validators != null
? Colors.black54
: widget.isValidated
? Colors.red
: Colors.black54,
color: isShowError()
? Colors.red
: Colors.black54,
)), )),
), ),
child: Row( child: Row(
], ],
)), )),
), ),
Validators.stringNotNullOrEmpty(textController.text) &&
validators != null
? SizedBox()
: Text(
isShowError()
? Text(
widget.isValidated widget.isValidated
? 'Vui lòng nhập ${widget.hint}' ? 'Vui lòng nhập ${widget.hint}'
: '', : '',
color: Colors.red, color: Colors.red,
fontWeight: FontWeight.normal), fontWeight: FontWeight.normal),
textAlign: TextAlign.left, textAlign: TextAlign.left,
),
)
: SizedBox(),
Container( Container(
height: 0, height: 0,
child: TextFormField( child: TextFormField(
); );
}); });
} }

bool isShowError() {
if (widget.validator == null) {
return false;
} else {
if (widget.isValidated) {
return Validators.stringNotNullOrEmpty(textController.text)
? false
: true;
} else {
return false;
}
}
}
} }

Loading…
Cancel
Save