Activity Feed
Loading preview
Starting the Flutter app
Timeline with vertical connector, activity icons
import 'package:flutter/material.dart';
const _activities = [
{'icon': Icons.favorite, 'text': 'Liked your post'},
{'icon': Icons.comment, 'text': 'Commented on your photo'},
{'icon': Icons.person_add, 'text': 'Started following you'},
];
class ActivityFeed extends StatelessWidget {
const ActivityFeed({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('Activity')),
body: ListView.builder(
itemCount: _activities.length,
itemBuilder: (context, i) {
final a = _activities[i];
return IntrinsicHeight(
child: Row(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
const SizedBox(width: 24),
Column(
children: [
Container(
width: 40,
height: 40,
decoration: BoxDecoration(
color: Colors.primaries[i % Colors.primaries.length].withValues(alpha: 0.3),
shape: BoxShape.circle,
),
child: Icon(a['icon'] as IconData, size: 20),
),
if (i < _activities.length - 1)
Expanded(
child: Container(
width: 2,
color: Colors.grey.withValues(alpha: 0.5),
),
),
],
),
const SizedBox(width: 16),
Expanded(
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 16),
child: Text(a['text'] as String),
),
),
],
),
);
},
),
);
}
}
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
Rows form a vertical timeline. IntrinsicHeight lets the connector line, an Expanded Container, stretch to match the row, and it’s skipped on the final item. Entries in _activities only hold an icon and text, so nothing says who acted or when. The dot color indexes Colors.primaries with a modulo, so it repeats on long lists.
Adapting it
- Add actor, timestamp and target fields to
_activitiesbefore connecting a feed. - Map colors from the activity type instead of the row index.
- Watch
IntrinsicHeightcosts on long lists; a fixed row height would avoid the extra layout pass.