I was following this stack-overflow to implement a timer operations at a one-second interval and is getting the captioned error. What do I have to do?
floatingActionButton: FloatingActionButton(
child: Icon(Icons.add),
onPressed: () async {
Timer.periodic(Duration(seconds:1), (Timer t) => print(t));
}
);
Error:
lib/main.dart:182:48: Error: 'Timer' isn't a type.
Timer.periodic(Duration(seconds:1), (Timer t) => print(t));
^^^^^
lib/main.dart:182:11: Error: The getter 'Timer' isn't defined for the class '_UploadPageState'.
- '_UploadPageState' is from 'package:decg_main/main.dart' ('lib/main.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'Timer'.
Timer.periodic(Duration(seconds:1), (Timer t) => print(t));