Here's the sample code.
`class _FormBuilderDatePickerFieldState extends State {
String? seletedDate;
FocusNode dateTimePickerFocusNode = new FocusNode();
FocusNode textFormFieldFocusNode = new FocusNode();
@OverRide
void initState() {
super.initState();
}
@OverRide
Widget build(BuildContext context) {
return Column(
children: [
DateTimePicker(
type: DateTimePickerType.date,
dateMask: 'MMMM d, yyyy',
//initialValue: DateTime.now().toString(),
focusNode: dateTimePickerFocusNode,
initialValue: seletedDate,
firstDate: DateTime(1940),
lastDate: DateTime(2100),
decoration: InputDecoration(
labelText: widget.labelText,
hintText: 'Select a date',
),
onChanged: (val) {
seletedDate = val;
},
validator: widget.validator,
onSaved: (val) => print(val)
),
TextFormField(
decoration: InputDecoration(
border: UnderlineInputBorder(),
labelText: 'First Text Box'
),
focusNode: textFormFieldFocusNode,
),
SizedBox(height: 1000),
TextFormField(
decoration: InputDecoration(
border: UnderlineInputBorder(),
labelText: 'Last Text Box'
),
),
RaisedButton(
child: Text('Focus to DateTimePicker'),
onPressed: () {
dateTimePickerFocusNode.requestFocus();
},
),
RaisedButton(
child: Text('Focus to TextFormfield'),
onPressed: () {
textFormFieldFocusNode.requestFocus();
},
),
],
);
}
}`
So basically I created 3 fields (1Datetime picker and a textfields) and 2 buttons that each triggers the focus for DateTimePicker and TextField. Triggering the requestFocus() for DateTimePicker only highlights the field but does not scroll the view. Scroll focus works in the text field.