This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
settings_ui is a published Flutter package (pub.dev: settings_ui, current version: 2.0.3) that renders native-looking settings screens for Android, iOS, macOS, Windows, Linux, Fuchsia, and Web — all from a single API. It is used in production by thousands of apps.
# Get dependencies
flutter pub get
# Run all tests
flutter test
# Run a single test file
flutter test test/widget_test.dart
# Run tests with coverage
flutter test --coverage --test-randomize-ordering-seed random
# Analyze for lint errors
flutter analyze .
# Fix formatting
flutter format .
# Check formatting without changing files (CI-style)
flutter format --set-exit-if-changed .
# Run the example app
cd example && flutter runEvery public widget (SettingsList, SettingsSection, SettingsTile) is a thin dispatcher. At build time each checks SettingsTheme.of(context).platform and returns one of three concrete platform implementations:
Android/Fuchsia/Linux→ Material widgetsiOS/macOS/Windows→ Cupertino widgetsWeb→ Web-specific widgets (rounded cards, adjusted padding)
Platform implementations live alongside their dispatcher:
lib/src/tiles/
settings_tile.dart ← dispatcher
platforms/
android_settings_tile.dart
ios_settings_tile.dart
web_settings_tile.dart
Same pattern for sections/ and list/.
SettingsList resolves platform and brightness, calls ThemeProvider.getTheme() to get hardcoded platform defaults, merges in any user-supplied lightTheme/darkTheme (SettingsThemeData), then pushes the result down the tree via SettingsTheme (an InheritedWidget).
All platform tile/section widgets read theme from SettingsTheme.of(context).themeData. Never pass theme as a constructor argument.
ThemeProvider (lib/src/utils/theme_provider.dart) contains all hardcoded color values for each platform/brightness combination. This is the main place to touch when fixing theme issues.
DevicePlatform.device means "auto-detect at runtime" and is valid only as input to SettingsList. It must never reach the platform switch statements inside tiles/sections — doing so throws. PlatformUtils.detectPlatform() resolves it to a real platform.
An extra InheritedWidget injected by IOSSettingsSection to tell each IOSSettingsTile whether to draw top/bottom border radius and whether to show the inter-tile divider. This is iOS/macOS/Windows only.
lib/settings_ui.dart re-exports exactly:
SettingsList(+ApplicationTypeenum)SettingsSection,AbstractSettingsSection,CustomSettingsSectionSettingsTile(+SettingsTileTypeenum),AbstractSettingsTile,CustomSettingsTileDevicePlatform,PlatformUtilsSettingsTheme,SettingsThemeData
Platform-specific implementations are internal and should not be part of the public API.
- Tests live in
test/with a flatwidget_test.dartentry point that calls helper functions grouped by concern (settingsListTests,settingsSectionsTests,settingsTileTests, etc.). - Helper test functions are parameterised over
DevicePlatformand called for every platform value. - The
_wrapWithMaterialApp/TestWidgetScreenhelper wraps a tile or section in aSettingsListinside aMaterialAppand passes the desired platform explicitly so tests are platform-deterministic. - CI requires ≥ 35% line coverage (
very_good_coverage).
- CI runs on every push: format check →
flutter analyze→flutter test --coverage→ coverage gate (35%). - PR titles must follow Conventional Commits (enforced by
action-semantic-pull-request). - There is currently no automated publish workflow; a new version requires bumping
versioninpubspec.yaml, updatingCHANGELOG.md, tagging, then runningflutter pub publish.