title: The method 'call' was called on null
body: <p>I am currently working on an app the takes datetime from user and stores it.
  I am using a callback that passes datetime from child to parent but keep getting the following error.</p>
  
  <p>In DateTimePicker class, onPressed executes the callBack function where it passes the date to its parent and that is probably where my issue is.</p>
  
  <p>I am new to flutter and I think my code is a bit messy but some help would be highly appreciated.</p>
  
  <pre><code>     The following NoSuchMethodError was thrown while handling a gesture:
       The method 'call' was called on null.
       Receiver: null
       Tried calling: call(Instance of 'DateTime')
  </code></pre>
  
  <p>Code from child class(where I think is the issue)</p>
  
  <pre><code>     import 'package:flutter/material.dart';
  
      import 'package:flutter_datetime_picker/flutter_datetime_picker.dart';
      import 'package:intl/intl.dart';
  
      class DateTimePicker extends StatelessWidget {
  
        final Function callBack;
  
        const DateTimePicker({Key key, this.callBack}) : super(key: key);
  
        @override
        Widget build(BuildContext context) {
          String _date = "Not set";
          return Container(
            padding: EdgeInsets.only(left: 15, right: 15),
            child: Column(
              children: &lt;Widget&gt;[
                RaisedButton(
                  shape: RoundedRectangleBorder(
                    borderRadius: BorderRadius.circular(8.0),
                  ),
                  elevation: 4.0,
                  onPressed: () {
                    DatePicker.showDatePicker(context,
                        theme: DatePickerTheme(
                          containerHeight: 250.0,
                          cancelStyle: TextStyle(
                              fontFamily: 'Lato', fontSize: 22, color: Colors.red),
                          doneStyle: TextStyle(
                              fontFamily: 'Lato', fontSize: 22, color: Colors.blue),
                          itemStyle: TextStyle(
                              fontFamily: 'Montserrat',
                              fontSize: 20,
                              color: Colors.black),
                          itemHeight: 50,
                        ),
                        showTitleActions: true,
                        minTime: DateTime(2000, 1, 1),
                        maxTime: DateTime(2022, 12, 31), onConfirm: (date) {
                      print('confirm $date');
                      callBack(date);
                      _date = DateFormat.yMMMd().format(date);
                    }, currentTime: DateTime.now(), locale: LocaleType.en);
                  },
                  child: Container(
                    alignment: Alignment.center,
                    height: 65,
                    child: Row(
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      children: &lt;Widget&gt;[
                        Row(
                          children: &lt;Widget&gt;[
                            Container(
                              child: Row(
                                children: &lt;Widget&gt;[
                                  Icon(
                                    Icons.calendar_today,
                                    size: 28.0,
                                    color: Colors.white,
                                  ),
                                  SizedBox(
                                    width: 20,
                                  ),
                                  Text(
                                    " $_date",
                                    style: TextStyle(
                                        color: Colors.white,
                                        fontSize: 22.0,
                                        fontFamily: 'Lato'),
                                  ),
                                ],
                              ),
                            )
                          ],
                        ),
                        Text(
                          "  Change",
                          style: TextStyle(
                              color: Colors.white,
                              fontSize: 20.0,
                              fontFamily: 'Lato'),
                        ),
                      ],
                    ),
                  ),
                  color: Color.fromRGBO(79, 67, 67, 1),
                )
              ],
            ),
          );
        }
      }
  </code></pre>
  
  <p>Code from Parent class</p>
  
  <pre><code>  import 'package:flutter/material.dart';
  
      import '../widgets/date_picker.dart';
      import 'package:provider/provider.dart';
      import '../providers/event_provider.dart';
  
      class EventPicker extends StatefulWidget {
        @override
        _EventPickerState createState() =&gt; _EventPickerState();
      }
  
      class _EventPickerState extends State&lt;EventPicker&gt; {
        String eventName;
  
        String dateTime;
  
        void callBack(DateTime dateFromChild) {
          this.dateTime = dateFromChild.toIso8601String();
        }
  
        @override
        Widget build(BuildContext context) {
          final add = Provider.of&lt;EventProviders&gt;(context);
  
          return SingleChildScrollView(
            child: Center(
              child: Container(
                child: Column(
                  children: &lt;Widget&gt;[
                    Padding(
                      padding: const EdgeInsets.only(top: 40, bottom: 60.0),
                      child: Text(
                        'Add Events',
                        style: Theme.of(context).textTheme.headline,
                      ),
                    ),
                    DateTimePicker(),
                    SizedBox(height: 27),
                    Theme(
                      data: ThemeData(
                        primaryColor: Colors.grey,
                        primaryColorDark: Colors.red,
                        fontFamily: 'Lato',
                      ),
                      child: Padding(
                        padding: const EdgeInsets.only(left: 15.0, right: 15.0),
                        child: TextField(
                          onChanged: (value) {
                            eventName = value;
                          },
                          autofocus: true,
                          decoration: InputDecoration(
                            border: OutlineInputBorder(),
                            labelText: 'Event',
                            labelStyle: TextStyle(
                              color: Colors.white,
                              fontFamily: 'Montserrat',
                            ),
                            hintText: 'eg: Exam ',
                            hintStyle: TextStyle(color: Colors.white, fontSize: 20)
                                .copyWith(fontFamily: 'Lato'),
                          ),
                          maxLength: 20,
                          style: TextStyle(color: Colors.white, fontSize: 22),
                          cursorColor: Colors.white,
                        ),
                      ),
                    ),
                    SizedBox(
                      height: 10,
                    ),
                    IconButton(
                      onPressed: () =&gt; add.addEvent(eventName, dateTime),
                      icon: Icon(
                        Icons.save,
                        color: Colors.white,
                        size: 30,
                      ),
                    ),
                    Text(
                      'Save',
                      style: Theme.of(context).textTheme.body2,
                    ),
                  ],
                ),
              ),
            ),
          );
        }
      }
  </code></pre>