Empty state
An empty state explains what belongs in a collection before its first item appears. When there is a natural first step, put that action beside the explanation.
Start a reading list
#Add the first book. It replaces the empty state. Remove it to see the original invitation again.
components/empty-state/appliance/start_list.dart
import 'package:flutter/widgets.dart';
import 'package:appliance_ui/appliance_ui.dart';
class StartList extends StatefulWidget {
const StartList({super.key});
@override
State<StartList> createState() => _StartListState();
}
class _StartListState extends State<StartList> {
bool added = false;
@override
Widget build(BuildContext context) => ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 440),
child: SingleChildScrollView(
child: added
? Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Text('A Field Guide'),
const SizedBox(height: 12),
ApplianceButton(
'Remove book',
onPressed: () => setState(() => added = false),
),
],
)
: ApplianceEmptyState(
title: 'No books yet',
message: 'Books you save will appear here.',
action: ApplianceButton(
'Add book',
onPressed: () => setState(() => added = true),
),
),
),
);
}
Parameters
ApplianceEmptyState API ↗title- The heading.
message- What goes here.
action- The key that puts something here.
reading- What the window reads.
style- Overrides the component’s themed appearance for this instance.
Shared behaviour
- Keyboard and focus. Tab to Add book and activate it. In the populated view, use Remove book to return to the empty list.
- Screen readers. Read the empty heading and its action. After adding the book, read the title that replaces the invitation.
- Direction and type. The heading, explanation and action follow the reading direction. Try them at phone width and 200% text.