I have a statefull widget
class Period extends StatefulWidget{
final StreamController<List<dynamic>> notify = StreamController<List<dynamic>>();
final int period;
Period(List<dynamic> data, this.period){
notify.sink.add(data);
print("created new Period:");
print(period);
}
void dispose() {
notify.close();
}
@override
_PeriodState createState() => _PeriodState();
}
class _PeriodState extends State<Period> {
bool isNull = true;
bool isListening = false;
List<Widget> lessons;
_PeriodState(){
lessons = [(genTime())];
widget.notify.stream.listen(update);
isListening = true;
}
}
But on the line widget.notify.stream.listen(update); it catches the exception "The getter 'notify' was called on null."
Why would widget be null? I print out the List the Periods are part of, but all of them are initialized properly.