I have two callback functions in a stateful widget which are called by two different screens. Here is the how I declared them in the stateful widget(onChange and finalBetList);
class AppListView extends StatefulWidget {
final ValueChanged onChange;
final List<MatchList> matchList;
final ValueChanged finalBetList;
AppListView({this.onChange, this.matchList, this.finalBetList});
And this is how I implemented them in the state class of the widget. Even if I try to pass the same parameter onChange working perfectly but finalBetList getting this error. The method 'call' was called on null.Receiver: null Tried calling: call(1)
widget.onChange(counter);
widget.finalBetList(counter);
Everything is same, one of them is workiing but other one get the error. What I'm missing?
Edit
This is the code where I call my stateful widget from HomeScreen(which works perfect)
Stack(children: [
AppListView(
matchList: matchList,
//callback function brings the counter value from ListView class
onChange: (value) {
setState(() {
counter = value;
});
},
),
This is the code where I call my stateful widget from second secreen(which gets error)
body: Container(
child: AppListView(
onChange: (value) {},
finalBetList: (value) {
counter = value;
setState(() {
//counter = value;
});
},
matchList: matchList),
),