title: Unhandled Exception: type '(dynamic) => Null' is not a subtype of type '(String, dynamic) => void' of 'f'
body: <p>I'm getting error like 
  Unhandled Exception: type '(dynamic) => Null' is not a subtype of type '(String, dynamic) => void' of 'f'</p>
  
  <p>I'm receiving a data list of events from the api which will be shown below</p>
  
  <pre><code>{events: [
  {
      _id: 5eac064141cd6224343f2bb8, 
      titleOfTheEvent: asdasd, 
      startingDateOfTheEvent: 2020-05-03 00:00:00.000, 
      endingDateOfTheEvent: 2020-05-04 00:00:00.000, 
      industry: dasdas, 
      venue: sadasdd, 
      numberOfStalls: 2, 
      stallBookingContactNumber: 9087654321, 
      description: sdasdasd, 
      creatorOfTheEvent: 5e8f15c22f955416f85ae7eb, 
      createdAt: 2020-05-01T11:21:37.244Z, 
      updatedAt: 2020-05-01T11:21:37.244Z,
       __v: 0
  },  
  {
      _id: 5eac0a0ddd0bb6474428dd21, 
      titleOfTheEvent: Worl something day, 
      startingDateOfTheEvent: 2020-05-02 00:00:00.000, 
      endingDateOfTheEvent: 2020-05-04 00:00:00.000, 
      industry: Automobile, 
      venue: Bangalore, 
      numberOfStalls: 5, 
      stallBookingContactNumber: 9087654321, 
      description: asd, 
      creatorOfTheEvent: 5e8f15c22f955416f85ae7eb, 
      createdAt: 2020-05-01T11:37:49.816Z, 
      updatedAt: 2020-05-01T11:37:49.816Z,
       __v: 0
  }]
  }
  </code></pre>
  
  <p>I'm trying to set that to display the data but I'm getting an error</p>
  
  <pre><code>  Future&lt;void&gt; fetchAndSetEvents() async{
  const url ='http://10.0.2.2:8080/event/events';
  try{
    final response = await http.get(url);
    final extractedData = json.decode(response.body) as Map&lt;String, dynamic&gt;;
    if(extractedData == null){
      return;
    }
    final List&lt;Event&gt; loadedEvents =[];
    extractedData.forEach((eventData){
      loadedEvents.add(Event(
      id:eventData['_id'],
      title:eventData['titleOfTheEvent'],
      eventStartDate:eventData['startingDateOfTheEvent'],
      eventEndDate:eventData['endingDateOfTheEvent'],
      venue:eventData['industry'],
      industry:eventData['venue'],
      numberOfStalls:eventData['numberOfStalls'],
      contactNumber:eventData['stallBookingContactNumber'],
      description:eventData['description'],
      ));
    });
    _events = loadedEvents;
    notifyListeners();
  }catch(error){
    print(error);
    throw(error);
  }
  }
  </code></pre>
  
  <p>I'm calling the function from stateful widget</p>
  
  <pre><code>  @override
    void didChangeDependencies() {
    if(_isInit){
    setState(() {
      _isLoading = true;
    });
    Provider.of&lt;Events&gt;(context).fetchAndSetEvents().then((_){
      setState(() {
        _isLoading=false;
      });
     });
     }
     _isInit=false;
     super.didChangeDependencies();
     }
  </code></pre>
  
  <p>the stack trace I'm getting is</p>
  
  <pre><code>E/flutter ( 7567): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled 
  Exception: type '(dynamic) =&gt; Null' is not a subtype of type '(String,                 
  dynamic) =&gt; void' of 'f'
  E/flutter ( 7567): #0      Events.fetchAndSetEvents 
  package:scopemobileapp/providers/events.dart:57
  E/flutter ( 7567): &lt;asynchronous suspension&gt;
  E/flutter ( 7567): #1      _ProducerAllProjectsState.didChangeDependencies 
  package:scopemobileapp/…/producer/producer_projects.dart:36
  E/flutter ( 7567): #2      StatefulElement._firstBuild 
  package:flutter/…/widgets/framework.dart:4376
  E/flutter ( 7567): #3      ComponentElement.mount 
  package:flutter/…/widgets/framework.dart:4201
  E/flutter ( 7567): #4      Element.inflateWidget 
  package:flutter/…/widgets/framework.dart:3194
  E/flutter ( 7567): #5      Element.updateChild 
  package:flutter/…/widgets/framework.dart:2988
  E/flutter ( 7567): #6      SingleChildRenderObjectElement.mount 
  package:flutter/…/widgets/framework.dart:5445
  E/flutter ( 7567): #7      Element.inflateWidget 
  package:flutter/…/widgets/framework.dart:3194
  E/flutter ( 7567): #8      Element.updateChild 
  package:flutter/…/widgets/framework.dart:2988
  E/flutter ( 7567): #9      ComponentElement.performRebuild 
  package:flutter/…/widgets/framework.dart:4243
  E/flutter ( 7567): #10     Element.rebuild 
  package:flutter/…/widgets/framework.dart:3947
  E/flutter ( 7567): #11     ComponentElement._firstBuild package:flutter/ 
  …/widgets/framework.dart:4206
  E/flutter ( 7567): #12     ComponentElement.mount 
  package:flutter/…/widgets/framework.dart:4201
  E/flutter ( 7567): #13     Element.inflateWidget 
  package:flutter/…/widgets/framework.dart:3194
  E/flutter ( 7567): #14     Element.updateChild 
  package:flutter/…/widgets/framework.dart:2988
  E/flutter ( 7567): #15     SingleChildRenderObjectElement.mount 
  package:flutter/…/widgets/framework.dart:5445
  E/flutter ( 7567): #16     Element.inflateWidget 
  package:flutter/…/widgets/framework.dart:3194
  E/flutter ( 7567): #17     Element.updateChild 
  package:flutter/…/widgets/framework.dart:2988
  E/flutter ( 7567): #18     SingleChildRenderObjectElement.mount 
  package:flutter/…/widgets/framework.dart:5445
  E/flutter ( 7567): #19     Element.inflateWidget 
  package:flutter/…/widgets/framework.dart:3194
  E/flutter ( 7567): #20     Element.updateChild 
  package:flutter/…/widgets/framework.dart:2988
  E/flutter ( 7567): #21     ComponentElement.performRebuild 
  package:flutter/…/widgets/framework.dart:4243
  E/flutter ( 7567): #22     Element.rebuild 
  package:flutter/…/widgets/framework.dart:3947
  E/flutter ( 7567): #23     ComponentElement._firstBuild 
  package:flutter/…/widgets/framework.dart:4206
  E/flutter ( 7567): #24     StatefulElement._firstBuild 
  package:flutter/…/widgets/framework.dart:4381
  E/flutter ( 7567): #25     ComponentElement.mount 
  package:flutter/…/widgets/framework.dart:4201
  E/flutter ( 7567): #26     Element.inflateWidget 
  package:flutter/…/widgets/framework.dart:3194
  E/flutter ( 7567): #27     Element.updateChild 
  package:flutter/…/widgets/framework.dart:2988
  E/flutter ( 7567): #28     SingleChildRenderObjectElement.mount 
  package:flutter/…/widgets/framework.dart:5445
  E/flutter ( 7567): #29     Element.inflateWidget 
  package:flutter/…/widgets/framework.dart:3194
  E/flutter ( 7567): #30     Element.updateChild 
  package:flutter/…/widgets/framework.dart:2988
  E/flutter ( 7567): #31     SingleChildRenderObjectElement.mount 
  package:flutter/…/widgets/framework.dart:5445
  E/flutter ( 7567): #32     Element.inflateWidget 
  package:flutter/…/widgets/framework.dart:3194
  E/flutter ( 7567): #33     Element.updateChild 
  package:flutter/…/widgets/framework.dart:2988
  E/flutter ( 7567): #34     ComponentElement.performRebuild 
  package:flutter/…/widgets/framework.dart:4243
  E/flutter ( 7567): #35     Element.rebuild 
  package:flutter/…/widgets/framework.dart:3947
  E/flutter ( 7567): #36     ComponentElement._firstBuild 
  package:flutter/…/widgets/framework.dart:4206
  E/flutter ( 7567): #37     StatefulElement._firstBuild 
  package:flutter/…/widgets/framework.dart:4381
  E/flutter ( 7567): #38     ComponentElement.mount 
  package:flutter/…/widgets/framework.dart:4201
  E/flutter ( 7567): #39     Element.inflateWidget 
  package:flutter/…/widgets/framework.dart:3194
  E/flutter ( 7567): #40     Element.updateChild 
  package:flutter/…/widgets/framework.dart:2988
  E/flutter ( 7567): #41     ComponentElement.performRebuild 
  package:flutter/…/widgets/framework.dart:4243
  E/flutter ( 7567): #42     Element.rebuild 
  package:flutter/…/widgets/framework.dart:3947
  E/flutter ( 7567): #43     ComponentElement._firstBuild 
  </code></pre>