utils/design_system/lib/src/empty_state.dart
Krzysztof kuhy Rudnicki 522fa1dff0 Wire design_system into CI, and drop EmptyState's speculative action slot
The pre-push coverage gate only ran for whoever had the local hook
installed, which is deployment hygiene rather than a gate. Adds the
mirrored workflow sync_settings_ui already has, so the 100% bar is
enforced on push and PR.

EmptyState.action was invented surface: no donor had it. home_inventory's
three call sites are pure placeholders, and kuhylog's action-bearing
_empty was explicitly excluded from the survey as a different element.
Shipping a parameter nobody asked for on a widget that has no consumer
yet is the failure mode this package is supposed to avoid, so it goes,
with a comment recording why rather than leaving the next reader to
rediscover it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XS1m7b1piBtAL22USLW6jL
2026-08-14 23:08:59 +02:00

64 lines
1.9 KiB
Dart

/// The placeholder shown when a list has nothing in it.
library;
import 'package:design_system/src/tokens.dart';
import 'package:flutter/material.dart';
/// A centred icon, headline and explanation for an empty list.
///
/// Promoted from `home_inventory` — the only one of four fleet variants that
/// was already a reusable widget rather than an inlined `Column`.
class EmptyState extends StatelessWidget {
/// Creates an empty-state placeholder.
const EmptyState({
required this.icon,
required this.title,
required this.message,
super.key,
});
/// Glyph shown above the text.
final IconData icon;
/// Short headline, e.g. "Nothing here yet".
final String title;
/// One line explaining what to do about it.
final String message;
// Deliberately no `action` slot. No donor had one: home_inventory's three
// call sites are pure placeholders, and kuhylog's action-bearing `_empty`
// is a different element. Adding one here would be speculative surface --
// the widget nobody imports, one parameter down.
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
return Center(
child: Padding(
padding: const EdgeInsets.all(AppSpacing.xl),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Icon(
icon,
size: AppSpacing.xxl,
color: theme.colorScheme.onSurfaceVariant,
),
const SizedBox(height: AppSpacing.md),
Text(title, style: theme.textTheme.titleMedium),
const SizedBox(height: AppSpacing.sm),
Text(
message,
textAlign: TextAlign.center,
style: theme.textTheme.bodyMedium?.copyWith(
color: theme.colorScheme.onSurfaceVariant,
),
),
],
),
),
);
}
}