Skip to content

BUG: Wrong type comparison in _updateTaskStatus() — success snackbar never shows #222

Description

@Muneerali199

Is there an existing issue for this?

  • I have searched the existing issues

What happened?

In lib/screens/tasks/task_detail_screen.dart, the _updateTaskStatus() method compares the return value of updateTaskStatus() against the boolean true. However, updateTaskStatus() returns Future<Map<String, dynamic>>, not a bool. Comparing a Map to a bool is always false in Dart, so the success branch is unreachable — the success SnackBar never shows, and the task details are never reloaded after a status update.

Root Cause

// supabase_service.dart:1349
Future<Map<String, dynamic>> updateTaskStatus({...}) async {
  // returns {'success': true, ...} or {'success': false, 'error': ...}
}

// task_detail_screen.dart:81 — WRONG
final success = await _supabaseService.updateTaskStatus(...);
if (success == true) {  // ❌ Map == bool is ALWAYS false
  // This block is NEVER reached
  ScaffoldMessenger.of(context).showSnackBar(...success message...);
} else {
  // This block ALWAYS runs, even on actual success
  ScaffoldMessenger.of(context).showSnackBar(...failure message...);
}

Steps to Reproduce

  1. Open any task in the task detail screen
  2. Change the task status (e.g. from "open" to "in_progress")
  3. Observe: "Failed to update task status" error snackbar always shows, even when the update succeeds in the database

Expected Behavior

  • On success: show "Task status updated to ..." green snackbar and reload task details
  • On failure: show "Failed to update task status" red snackbar

Actual Behavior

  • Always shows the failure red snackbar regardless of actual result

Fix

// CORRECT — read the 'success' key from the returned Map
final result = await _supabaseService.updateTaskStatus(...);
if (result['success'] == true) {
  await _loadTaskDetails();
  ScaffoldMessenger.of(context).showSnackBar(...success...);
} else {
  ScaffoldMessenger.of(context).showSnackBar(...failure...);
}

Evidence

flutter analyze flags this:

info - The type of the right operand ('bool') isn't a subtype or a supertype
       of the left operand ('Map<String, dynamic>') 
       — lib/screens/tasks/task_detail_screen.dart:81:21 — unrelated_type_equality_checks

Record

  • I agree to follow this project's Code of Conduct
  • I want to work on this issue

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions