Going through this tutorial on Riverpod and using this code gives an error Unexpected text 'late'
class Clock extends StateNotifier<DateTime> {
Clock() : super(DateTime.now()) {
_timer = Timer.periodic(Duration(seconds: 1), (_) {
state = DateTime.now();
});
}
late final Timer _timer;
@override
void dispose() {
_timer.cancel();
super.dispose();
}
}
My code is exactly the same as found on the linked website. This error looks strange as I haven't found anything on google or stackoverflow similar to this.