我想在我的应用程序中解释一些内容并添加一个看起来像通知或聊天的小部件。我希望这个小部件在一段时间内可见,然后被解雇。我尝试使用tooltip
,但只有当我点击它时它才可见。我可以使用哪个小部件?
Dart包intro_views_flutter是你需要的,但它的一个主要限制是它全屏显示,如果这不是你的问题,那么你应该看看它。或者你可以这样在showDialog
函数中使用Future
方法:
Future showNotification() async {
showDialog<String>(
context: context,
child: new AlertDialog(
title: Text('Note!') ,
contentPadding: const EdgeInsets.all(16.0),
content: //any widget you want to display here
),
);
await new Future.delayed(const Duration(seconds: 5), () {
Navigator.of(context).pop(); // this will dismiss the dialog automatically after five seconds
}
}
然后当你需要它时:
showNotificaion();