Skip to content

fix: app crashes when creating transaction with empty description #112

Description

@MF-Rozi

Describe the bug

When saving a transaction with an empty description in TransactionEntryPage, the application crashes with an unhandled UnexpectedValueError.

Steps to Reproduce

  1. Open the new transaction screen (/transaction/new).
  2. Select an amount and choose a Category (Envelope).
  3. Leave the Description input blank.
  4. Tap Save Transaction.
  5. The application throws UnexpectedValueError on StringSingleLine.getOrCrash() during model conversion / entity instantiation and crashes.

Expected Behavior

  • The app should not crash.
  • If the description is left blank, the system should automatically generate a contextual description based on the transaction type and category name (e.g., Spending for Dining, Income from Salary, Investment in Stocks).
  • Users should be able to quickly log transactions without being strictly forced to type a custom description every time.

Proposed Fix

  • In TransactionCubit.submitTransaction(), evaluate if state.description.trim().isEmpty.
  • Dynamically build a fallback description:
    • Expense: Spending for <Category>
    • Income: Income from <Category>
    • Investment: Investment in <Category>
    • Transfer: Transfer for <Category>
    • Fallback: Transaction
  • Add unit tests in transaction_cubit_test.dart to ensure empty and whitespace descriptions never crash and correctly generate contextual defaults.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions