In the below code widget.hintText is giving the error, I am trying to make the datepicker as the seperate component and dynamically pass the hinttext value whenever calling it from the other file.
import 'package:date_field/date_field.dart';
import 'package:flutter/material.dart';
class DatePicker extends StatefulWidget {
final String hintText;
DatePicker({
this.hintText,
Key key,
}): super(key: key);
@override
_DatePickerState createState() => _DatePickerState();
}
class _DatePickerState extends State<DatePicker> {
@override
Widget build(BuildContext context) {
return DateTimeFormField(
decoration: const InputDecoration(
hintText: widget.hintText,
hintStyle: TextStyle(color: Colors.black54,fontSize: 16),
errorStyle: TextStyle(color: Colors.redAccent),
suffixIcon: Icon(Icons.event_note),
),
mode: DateTimeFieldPickerMode.date,
autovalidateMode: AutovalidateMode.always,
// validator: (e) => (e?.day ?? 0) == 1 ? 'Please not the first day' : null,
onDateSelected: (DateTime value) {
},
);
}
}