title: Flutter get all variable null using selector provider
body: <p>I have this provider class:</p>
  <pre><code>import 'package:flutter/material.dart';
  
  class DateProvider with ChangeNotifier {
    DateTime? _date1 = null;
    DateTime? _date2 = null;
  
    DateTime? get date1 =&gt; _date1;
    DateTime? get date2 =&gt; _date2;
  
    void changeDate1(DateTime? date1) {
      _date1 = date1;
      notifyListeners();
    }
  
    void changeDate2(DateTime? date2) {
      _date2 = date2;
      notifyListeners();
    }
  }
  </code></pre>
  <p>I have two TextFormFields wrapped with Selector when I press on the first one to pick date</p>
  <pre><code>class _TestState extends State&lt;Test&gt; {
        var _formKey = GlobalKey&lt;FormState&gt;();
        var _date2Key = GlobalKey&lt;FormState&gt;();
      
        TextEditingController _date1Controller = TextEditingController();
        TextEditingController _date2Controller = TextEditingController();
        @override
        Widget build(BuildContext context) {
          return Scaffold(
            appBar: AppBar(),
            body: Form(
              key: _formKey,
              child: Column(
                children: [
                  Selector&lt;DateProvider, DateTime?&gt;(
                      selector: (_, provider) =&gt; provider.date1,
                      builder: (context, date1, child) {
                        return TextFormField(
                          controller: _date1Controller,
                          autovalidateMode: AutovalidateMode.onUserInteraction,
                          validator: (value) {
                            print(&quot;Validator $date1&quot;);
                            return;
                          },
                          readOnly: true,
                          onTap: () async {
                            DateTime? pickedDate = await showDatePicker(
                              context: context,
                              initialDate: date1 != null ? date1 : DateTime.now(),
                              firstDate: DateTime.now(),
                              lastDate: DateTime(2101),
                            );
      
                            if (pickedDate != null) {
                              Provider.of&lt;DateProvider&gt;(context, listen: false)
                                  .changeDate1(pickedDate);
      
                              print(&quot;TextFormField1 date: $date1&quot;);
      
                              _date2Key.currentState!.validate();
                              _formKey.currentState!.validate();
                            }
                          },
                        );
                      }),
                  Selector&lt;DateProvider, Tuple2&lt;DateTime?, DateTime?&gt;&gt;(
                      selector: (_, provider) =&gt;
                          Tuple2(provider.date1, provider.date2),
                      builder: (context, data, child) {
                        return Form(
                          key: _date2Key,
                          child: TextFormField(
                            controller: _date2Controller,
                            autovalidateMode: AutovalidateMode.onUserInteraction,
                            validator: (value) {
                              print(&quot;Validator2  date1 :${data.item1}&quot;);
                              print(&quot;Validator2  date2 :${data.item2}&quot;);
      
                              return;
                            },
      
                            readOnly:
                                true, //set it true, so that user will not able to edit text
                            onTap: () async {
                              DateTime? pickedDate = await showDatePicker(
                                context: context,
                                initialDate:
                                    data.item2 != null ? data.item2! : DateTime.now(),
                                firstDate: DateTime.now(),
                                lastDate: DateTime(2101),
                              );
      
                              if (pickedDate != null) {
                                Provider.of&lt;DateProvider&gt;(context, listen: false)
                                    .changeDate2(pickedDate);
                              }
                            },
                          ),
                        );
                      }),
                ],
              ),
            ),
          );
        }
      }
  </code></pre>
  <p>I want to change the date1 in provider class and validate that two textfromfield.
  When I pickDate in the first one all the date printed is null knowing that I wrapped the two textformfield with selector</p>
  <p>The console shows:</p>
  <pre><code>TextFormField1 date: null
  Validator2  date1 :null
  Validator2  date2 :null
  Validator null
  </code></pre>
  <p>why are the values null</p>