Event List
Loading preview
Starting the Flutter app
A showcase of Flutter's event list functionality
import 'package:flutter/material.dart';
const _events = [
{'title': 'Team Meeting', 'time': '10:00 AM', 'location': 'Room A'},
{'title': 'Lunch', 'time': '12:30 PM', 'location': 'Cafeteria'},
{'title': 'Design Review', 'time': '2:00 PM', 'location': 'Room B'},
{'title': 'Standup', 'time': '4:00 PM', 'location': 'Remote'},
];
class EventList extends StatelessWidget {
const EventList({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Today'),
actions: [
FilledButton.icon(
onPressed: () => _showDemo(context, 'Add event (demo)'),
icon: const Icon(Icons.add, size: 18),
label: const Text('Add'),
),
],
),
body: ListView.builder(
padding: const EdgeInsets.all(16),
itemCount: _events.length,
itemBuilder: (context, i) {
final e = _events[i];
return Card(
margin: const EdgeInsets.only(bottom: 8),
child: ListTile(
leading: Container(
width: 48,
height: 48,
decoration: BoxDecoration(
color: Colors.blue.withValues(alpha: 0.2),
borderRadius: BorderRadius.circular(8),
),
child: Icon(Icons.event, color: Colors.blue[700]),
),
title: Text(e['title'] as String),
subtitle: Text('${e['time']} • ${e['location']}'),
trailing: const Icon(Icons.chevron_right),
onTap: () => _showDemo(context, 'Open ${e['title']} (demo)'),
),
);
},
),
);
}
}
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
EventList maps a const _events list of string maps into Card-wrapped ListTiles through ListView.builder. Every row gets the same blue Icons.event tile, and the ‘Today’ title is a literal with no date logic behind it. Row taps and the Add button show a demo SnackBar.
Adapting it
- Replace the maps with a typed event class holding a
DateTime, which removes casts likee['title'] as String. - Load
_eventsper day through aFutureBuilderor your state layer, and filter by the selected date. - Colour the tile by event category instead of
Colors.blue, and open a detail screen fromonTapin place of_showDemo.