Photo Album
Loading preview
Starting the Flutter app
A showcase of Flutter's photo album functionality
import 'package:flutter/material.dart';
const _albums = [
{'name': 'Vacation 2025', 'count': 24},
{'name': 'Family', 'count': 56},
{'name': 'Work', 'count': 12},
];
class PhotoAlbum extends StatelessWidget {
const PhotoAlbum({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('Albums')),
body: ListView.builder(
padding: const EdgeInsets.all(16),
itemCount: _albums.length,
itemBuilder: (context, i) {
final a = _albums[i];
final color = Colors.primaries[i % Colors.primaries.length];
return Card(
margin: const EdgeInsets.only(bottom: 12),
child: ListTile(
leading: Container(
width: 56,
height: 56,
decoration: BoxDecoration(
color: color.withValues(alpha: 0.3),
borderRadius: BorderRadius.circular(8),
),
child: Icon(Icons.photo_library, color: color),
),
title: Text(a['name'] as String),
subtitle: Text('${a['count']} photos'),
trailing: const Icon(Icons.chevron_right),
onTap: () => _showDemo(context, 'Open ${a['name']} (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
_albums holds three name and count pairs, listed as ListTiles with a tinted photo_library icon in each leading slot. The subtitle always appends “photos”, so an album with one item would read “1 photos”. onTap shows a demo SnackBar, so albums don’t open yet.
Adapting it
- Use
onTapto push a photo grid for the tapped album. - Show a cover thumbnail in
leadingin place of the tintedContainer. - Load
_albumsfrom your API, or from the device through a package likephoto_manager.