FAQ Page
Loading preview
Starting the Flutter app
A showcase of Flutter's FAQ page functionality
import 'package:flutter/material.dart';
const _faqs = [
{'q': 'How do I get started?', 'a': 'Download the app and create an account to begin.'},
{'q': 'What payment methods do you accept?', 'a': 'We accept all major credit cards and PayPal.'},
{'q': 'Can I cancel anytime?', 'a': 'Yes, you can cancel your subscription at any time.'},
];
class FaqPage extends StatelessWidget {
const FaqPage({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('FAQ')),
body: ListView(
padding: const EdgeInsets.all(16),
children: _faqs.map((faq) {
return Card(
margin: const EdgeInsets.only(bottom: 8),
child: ExpansionTile(
title: Text(faq['q'] as String),
children: [
Padding(
padding: const EdgeInsets.all(16),
child: Text(faq['a'] as String),
),
],
),
);
}).toList(),
),
);
}
}
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
_faqs is a const list of question and answer maps, rendered as one ExpansionTile per Card. The page is a StatelessWidget: each tile manages its own open state, so several answers can stay open at the same time. The content is hardcoded in the file, there’s no search, and open tiles aren’t remembered after leaving the page.
Adapting it
- Load
_faqsfrom your CMS or API, and give it a typed model instead offaq['q'] as String. - For a true accordion, make the page stateful, give each tile an
ExpansibleControllerand collapse the others insideonExpansionChanged. - Add a search field that filters
_faqsfor longer lists.