Place Detail
Loading preview
Starting the Flutter app
A Flutter place detail sheet with photos, rating, hours, and directions and call actions.
import 'package:flutter/material.dart';
class PlaceDetail extends StatelessWidget {
const PlaceDetail({super.key});
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
final scheme = theme.colorScheme;
return Scaffold(
body: CustomScrollView(
slivers: [
SliverAppBar(
expandedHeight: 200,
pinned: true,
flexibleSpace: FlexibleSpaceBar(
background: Container(
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: [scheme.tertiary, scheme.primary],
),
),
child: const Center(
child: Icon(Icons.restaurant,
size: 72, color: Colors.white38),
),
),
),
),
SliverToBoxAdapter(
child: Padding(
padding: const EdgeInsets.all(20),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('Blue Fig Bistro',
style: theme.textTheme.headlineSmall
?.copyWith(fontWeight: FontWeight.bold)),
const SizedBox(height: 6),
Row(
children: [
const Icon(Icons.star, color: Colors.amber, size: 18),
const SizedBox(width: 4),
const Text('4.6'),
const SizedBox(width: 6),
Text('(1,284) · Mediterranean · \$\$',
style: TextStyle(color: scheme.onSurfaceVariant)),
],
),
const SizedBox(height: 6),
Row(
children: [
Icon(Icons.schedule,
size: 16, color: Colors.green),
const SizedBox(width: 6),
const Text('Open now',
style: TextStyle(color: Colors.green)),
Text(' · Closes 11 PM',
style: TextStyle(color: scheme.onSurfaceVariant)),
],
),
const SizedBox(height: 16),
Row(
children: [
Expanded(
child: FilledButton.icon(
onPressed: () => _showDemo(context, 'Directions (demo)'),
icon: const Icon(Icons.directions),
label: const Text('Directions')),
),
const SizedBox(width: 12),
Expanded(
child: OutlinedButton.icon(
onPressed: () => _showDemo(context, 'Call (demo)'),
icon: const Icon(Icons.call),
label: const Text('Call')),
),
],
),
const SizedBox(height: 20),
SizedBox(
height: 90,
child: ListView.separated(
scrollDirection: Axis.horizontal,
itemCount: 5,
separatorBuilder: (_, _) => const SizedBox(width: 10),
itemBuilder: (context, i) => Container(
width: 120,
decoration: BoxDecoration(
color: scheme.surfaceContainerHighest,
borderRadius: BorderRadius.circular(12),
),
child: Icon(Icons.photo,
color: scheme.onSurfaceVariant),
),
),
),
const SizedBox(height: 20),
const ListTile(
contentPadding: EdgeInsets.zero,
leading: Icon(Icons.location_on_outlined),
title: Text('12 Harbour Lane, Old Town'),
),
const ListTile(
contentPadding: EdgeInsets.zero,
leading: Icon(Icons.language),
title: Text('bluefigbistro.com'),
),
],
),
),
),
],
),
);
}
}
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
CustomScrollView pairs a pinned SliverAppBar with a single SliverToBoxAdapter that holds the details. The header is a gradient built from scheme.tertiary and scheme.primary with a faint icon, and the photo strip is five gray boxes from a horizontal ListView.separated. Everything about Blue Fig Bistro is hardcoded in the build method, and the buttons show a demo SnackBar through _showDemo.
Adapting it
- Accept a place model through the
PlaceDetailconstructor and bind name, rating and hours to it. - Use real images in
FlexibleSpaceBarand replaceitemCount: 5. - Wrap the long
Textin the ratingRowwithExpanded, since longer strings will overflow.