title: Flutter - How make selected value inside DatePicker to appear inside a TextFormField?
body: <p>What I did so far: I have an onTap () action inside a TextFormField. This onTap () action calls the _selectDate that opens the datepicker. Inside the _selectDate I'm using an auxiliary variable that I created called presentText and I assign this variable inside the initialValue of the TextFormField. The problem is that the initialValue is always blank, even if I change the date inside the datepicker, TextFormField's initialValue remains blank. In the debug I saw that the presentText is filled in correctly but I don't know why the value is not going to the TextFormField.</p>
  
  <pre><code>   class _DetailFormState extends State&lt;DetailForm&gt; {
                DateTime selectedDate = DateTime.now();
                String presentText;
  
                Future&lt;Null&gt; _selectDate(BuildContext context) async {
                  final DateTime picked = await showDatePicker(
                      context: context,
                      initialDate:
                          widget.user.birthday != null ? widget.user.birthday : selectedDate,
                      firstDate: DateTime(2015, 8),
                      lastDate: DateTime(2101));
                  if (picked != null &amp;&amp; picked != selectedDate)
                    setState(() {
                      selectedDate = picked;
                      widget.user.birthday = picked;
                      presentText = "${widget.user.birthday.toLocal()}" != null
                          ? "${widget.user.birthday.toLocal()}".split(' ')[0].toString()
                          : "${selectedDate.toLocal()}".split(' ')[0].toString();
                    });
                }
  
                @override
                Widget build(BuildContext context) {
                  return Scaffold(
                    body: SingleChildScrollView(
                      padding: EdgeInsets.symmetric(vertical: 8.0, horizontal: 16.0),
                      child: Form(
                        key: _formKey,
                        autovalidate: true,
                        child: Column(
                          children: &lt;Widget&gt;[
  
                               Padding(
                                padding: EdgeInsets.only(top: 15),
                                child: Text(
                                  'Birthday',
                                  textAlign: TextAlign.left,
                                  overflow: TextOverflow.ellipsis,
                                  style: TextStyle(fontWeight: FontWeight.bold),
                                )),
  
                            GestureDetector(
                                onTap: () =&gt; _selectDate(context),
                                child: AbsorbPointer(
                                    child: TextFormField(
                                  initialValue: presentText
                                ))),
                                 ],
                    ),
                  ],
                ),
              ),
            ),
          );
        }
  </code></pre>