【发布时间】:2020-12-01 09:58:04
【问题描述】:
我正在关注this stack-overflow 以一秒为间隔实现计时器操作,并收到标题错误。我该怎么办?
floatingActionButton: FloatingActionButton(
child: Icon(Icons.add),
onPressed: () async {
Timer.periodic(Duration(seconds:1), (Timer t) => print(t));
}
);
错误:
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));
【问题讨论】:
-
你也可以分享
_UploadPageState吗?
标签: flutter