Unhandled Exception: Future not completed

Unhandled Exception: Exception: Something went wrong

Quick Answer

An async Future threw an exception that was not caught.

Why This Happens

In Dart, when a Future throws an exception and there is no try-catch or .catchError handler, it becomes an unhandled exception. This can crash the app. Always wrap async calls in try-catch blocks or add error handlers to Futures.

The Problem

Future<void> loadData() async {
  final response = await http.get(Uri.parse('https://api.example.com/data'));
  final data = jsonDecode(response.body); // May throw
}

The Fix

Future<void> loadData() async {
  try {
    final response = await http.get(Uri.parse('https://api.example.com/data'));
    final data = jsonDecode(response.body);
  } catch (e) {
    debugPrint('Failed to load data: $e');
  }
}

Step-by-Step Fix

  1. 1

    Identify the error

    Look at the unhandled exception message and stack trace to determine which async operation threw the error.

  2. 2

    Find the cause

    Check if the Future has proper error handling with try-catch or .catchError, especially for network and parsing operations.

  3. 3

    Apply the fix

    Wrap the async operation in a try-catch block and handle the error appropriately, such as showing a user-friendly message.

Bugsly catches this automatically

Bugsly's AI analyzes this error pattern in real-time, explains what went wrong in plain English, and suggests the exact fix — before your users even report it.

Try Bugsly free