iT邦幫忙

0

19 : 整合任務優先權與提醒通知

  • 分享至 

  • xImage
  •  
  1. 設定任務優先權
    • 每個待辦事項可以設定優先級(高、中、低)
    • 在清單上以顏色或圖示標示不同優先級,方便快速辨識
// todo_item.dart
class ToDoItem {
 String title;
 bool isDone;
 String priority; // "高", "中", "低"
 
 ToDoItem({required this.title, this.isDone = false, this.priority = "中"});
}
  1. 新增提醒通知
    • 使用者可為每個任務設定提醒時間。
    • 當到達提醒時間時,應觸發通知或彈出提醒。
// todo_item.dart
DateTime? reminder; // 任務提醒時間
ToDoItem({required this.title, this.isDone = false, this.priority = "中", this.reminder});
  1. 顯示優先權與提醒
    • 在待辦清單上顯示任務優先權(可用顏色或文字標示)。
    • 若任務設有提醒,圖示或文字提示即將到期。

// todo_item_widget.dart
Widget build(BuildContext context) {
return ListTile(
title: Text(item.title),
leading: Icon(
Icons.label,
color: item.priority == "高" ? Colors.red : item.priority == "中" ? Colors.orange : Colors.green,
),
trailing: item.reminder != null
? Icon(Icons.notifications_active, color: Colors.blue)
: null,
onTap: () {
setState(() { item.isDone = !item.isDone; });
},
);
}
```

 ![https://ithelp.ithome.com.tw/upload/images/20251012/20178900L3Zba2VnYC.png](https://ithelp.ithome.com.tw/upload/images/20251012/20178900L3Zba2VnYC.png)

圖片
  熱門推薦
圖片
{{ item.channelVendor }} | {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言