title: access function values that has context - flutter
body: <p>I am writing a todo app with flutter. i have a timepicker and datepicker. i wanted to write a function that when I press the custom button, add the values to the database, instead of when i press ok in date or time picker. but I don't know what to give for context because i get context can't be null.
  here is the function and some variables.</p>
  <pre><code>BuildContext contextBuild;
  
    createTask () async {
      var date = selectDate(contextBuild);
      DatabaseHelper dbHelper = DatabaseHelper();
      Task newTask = Task(date: date.toString());
      await dbHelper.insertTask(newTask);
    }
  </code></pre>
  <p>and this is the timepicker function</p>
  <pre><code> selectDate(BuildContext context) async {
  final DateTime picked = await showDatePicker(
    builder: (context, child) {
      return Theme(
        data: ThemeData.light(),
        child: child,
      );
    },
    context: context,
    initialDate: selectedDate, // Refer step 1
    firstDate: DateTime(2020),
    lastDate: DateTime(2025),
  );
  if (picked != null){
    var formated = DateFormat.yMMMd().format(picked);
    return formated;
  } else if (picked == null) {
    var nullFormatted = DateFormat.yMMMd().format(selectedDate);
    return nullFormatted;
  }
  </code></pre>
  <p>}</p>