refactor: reduce duplication and improve readability of settings page

Open
#641 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

  • #642 by @chetanr25 — closed without merging

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
55/100
Issue type
Refactor
Clarity
Mostly clear
Activity status
Quiet
Tech stack
dart, flutter
Domain
mobile

Research direction

Start in lib/app/modules/settings/views/ and read the settings page plus the four listed toggle trailing files. Trace SupportedLanguage and the inline delete-tasks confirmation before planning the shared SettingsGroup, language-name getter, and extracted delete-tasks tile. Done means repeated section and toggle logic is consolidated, language names have one source, the dialog is extracted, and the five absorbed files are removed.

Written by the indexing model from the issue text.

Description

The settings page (lib/app/modules/settings/views/) has significant code duplication and readability
issues:

  • Repeated section boilerplate - _buildSectionHeader() and _buildSettingsCard() are called manually for
    every settings group with the same styling logic.
  • Near-identical toggle widgets - 4 separate files (settings_page_on_task_start_list_tile_trailing.dart,
    settings_page_on_task_create_list_tile_trailing.dart, settings_page_highlist_task_list_tile_trailing.dart,
    settings_page_enable_24hr_format_list_tile_trailing.dart) each containing ~30 lines that all do the same
    thing: Obx(() => Switch(...)).
  • Hardcoded language names - _getLanguageName() duplicates what should be part of the SupportedLanguage enum, requiring updates in multiple places when a language is added.
  • Large inline widgets - The delete-tasks confirmation dialog (~80 lines) is inlined directly in the body,
    hurting readability.

Proposed Changes

  1. Introduce SettingsGroup widget + SettingsItemConfig sealed class
    A single reusable widget that accepts title, icon, and a List and handles section
    header, card styling, and dividers internally. Three item types:
  • SettingsToggleItem - title, subtitle, RxBool value, optional prefsKey (auto-saves to SharedPreferences),
    optional onChanged for extra side effects
  • SettingsDropdownItem - title, subtitle, Rx value, options list, labelBuilder, onChanged
  • SettingsCustomItem wraps any custom widget
  1. Add nativeName getter to SupportedLanguage
    Centralizes display names so Dart's exhaustive switch enforces updates when new languages are added.

  2. Extract delete-tasks tile into SettingsPageDeleteTasksTile
    Moves the FutureBuilder + confirmation dialog into its own widget file.

  3. Delete absorbed files
    Remove the 5 single-purpose trailing widget files whose logic is now handled by SettingsGroup.

Dominant language
Dart
Stars
246
Forks
184
PR merge metrics
No merged PRs in 30d

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from CCExtractor/taskwarrior-flutter

All issues in CCExtractor/taskwarrior-flutter

Similar issues

More Dart issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.