Contact Page
Loading preview
Starting the Flutter app
A showcase of Flutter's contact page functionality
import 'package:flutter/material.dart';
class ContactPage extends StatelessWidget {
const ContactPage({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('Contact Us')),
body: Padding(
padding: const EdgeInsets.all(16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
TextField(
decoration: InputDecoration(
labelText: 'Name',
border: OutlineInputBorder(borderRadius: BorderRadius.circular(12)),
),
),
const SizedBox(height: 12),
TextField(
decoration: InputDecoration(
labelText: 'Email',
border: OutlineInputBorder(borderRadius: BorderRadius.circular(12)),
),
keyboardType: TextInputType.emailAddress,
),
const SizedBox(height: 12),
TextField(
decoration: InputDecoration(
labelText: 'Subject',
border: OutlineInputBorder(borderRadius: BorderRadius.circular(12)),
),
),
const SizedBox(height: 12),
TextField(
decoration: InputDecoration(
labelText: 'Message',
border: OutlineInputBorder(borderRadius: BorderRadius.circular(12)),
alignLabelWithHint: true,
),
maxLines: 5,
),
const SizedBox(height: 24),
FilledButton(
onPressed: () => _showDemo(context, 'Send Message (demo)'),
style: FilledButton.styleFrom(
padding: const EdgeInsets.symmetric(vertical: 16),
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
),
child: const Text('Send Message'),
),
const SizedBox(height: 24),
const Divider(),
ListTile(
leading: const Icon(Icons.email),
title: const Text('support@example.com'),
onTap: () => _showDemo(context, 'support@example.com (demo)'),
),
ListTile(
leading: const Icon(Icons.phone),
title: const Text('+1 (555) 123-4567'),
onTap: () => _showDemo(context, '+1 (555) 123-4567 (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
Four TextFields and a FilledButton sit in a plain Column, with email and phone ListTiles underneath. There are no controllers, no validation and no submit logic, so Send Message only shows a demo SnackBar and typed text is never read. The Column also isn’t scrollable, which means the layout will overflow once the keyboard opens on a short screen.
Adapting it
- Wrap the body in a
SingleChildScrollView, then aForm, and convert eachTextFieldto a validatedTextFormField. - Post the values to your backend from the
FilledButtoncallback. - Use
url_launcherin theListTileonTaphandlers formailto:andtel:links.