Reminders
Loading preview
Starting the Flutter app
A Flutter reminders screen with scheduled tasks grouped by day and toggle switches.
import 'package:flutter/material.dart';
class _Reminder {
final String title;
final String time;
final IconData icon;
bool on;
_Reminder(this.title, this.time, this.icon, this.on);
}
class _Group {
final String label;
final List<_Reminder> items;
const _Group(this.label, this.items);
}
class Reminders extends StatefulWidget {
const Reminders({super.key});
@override
State<Reminders> createState() => _RemindersState();
}
class _RemindersState extends State<Reminders> {
final _groups = [
_Group('Today', [
_Reminder('Team standup', '9:30 AM', Icons.groups_outlined, true),
_Reminder('Take medication', '1:00 PM', Icons.medication_outlined, true),
_Reminder('Call the bank', '4:15 PM', Icons.call_outlined, false),
]),
_Group('Tomorrow', [
_Reminder('Dentist appointment', '11:00 AM', Icons.local_hospital_outlined,
true),
_Reminder('Pay rent', 'All day', Icons.home_outlined, true),
]),
_Group('This week', [
_Reminder('Renew passport', 'Thu', Icons.badge_outlined, false),
_Reminder('Mom\'s birthday', 'Sat', Icons.cake_outlined, true),
]),
];
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
final scheme = theme.colorScheme;
return Scaffold(
appBar: AppBar(title: const Text('Reminders')),
floatingActionButton: FloatingActionButton(
onPressed: () => _showDemo(context, 'New reminder (demo)'), child: const Icon(Icons.add_alert)),
body: ListView(
padding: const EdgeInsets.symmetric(vertical: 8),
children: [
for (final g in _groups) ...[
Padding(
padding: const EdgeInsets.fromLTRB(20, 16, 20, 8),
child: Text(g.label,
style: theme.textTheme.titleSmall?.copyWith(
fontWeight: FontWeight.bold, color: scheme.primary)),
),
for (final r in g.items)
ListTile(
leading: CircleAvatar(
backgroundColor: scheme.surfaceContainerHighest,
child:
Icon(r.icon, size: 20, color: scheme.onSurfaceVariant),
),
title: Text(r.title),
subtitle: Text(r.time),
trailing: Switch(
value: r.on, onChanged: (v) => setState(() => r.on = v)),
),
],
],
),
);
}
}
void _showDemo(BuildContext context, String message) {
ScaffoldMessenger.of(context)
..hideCurrentSnackBar()
..showSnackBar(SnackBar(content: Text(message)));
}
Add it to your project
Copies the Dart source into your app, so you own it. Flutter SDK only, no extra packages.
First time? Run dart pub global activate fluttertemplates_dev, or read the CLI guide.
How it works
_groups nests mutable _Reminder objects inside _Group sections, rendered with collection for loops spreading a header and tiles into one ListView. A Switch flips r.on directly in setState. Nothing is scheduled, though: time is display text such as '9:30 AM' or 'Thu', and the add button shows a demo SnackBar. Sections are fixed labels, not computed dates.
Adapting it
- Store a
DateTimein_Reminder, and derive_Grouplabels from it. - Schedule or cancel with
flutter_local_notificationsfrom theSwitchonChanged. - Open a creation form from the
FloatingActionButton, and persist_groups.