FutureBuilder snapshot has no data

type 'Null' is not a subtype of type 'Widget'

Quick Answer

FutureBuilder was not handling the loading or error states of the snapshot.

Why This Happens

In Flutter, FutureBuilder goes through multiple ConnectionStates: none, waiting, active, done. If you only handle the done state and return the data widget, the waiting state returns null which cannot be used as a Widget. Always handle all snapshot states.

The Problem

FutureBuilder<String>(
  future: fetchData(),
  builder: (context, snapshot) {
    if (snapshot.hasData) {
      return Text(snapshot.data!);
    }
    // Returns null implicitly when loading!
  },
)

The Fix

FutureBuilder<String>(
  future: fetchData(),
  builder: (context, snapshot) {
    if (snapshot.connectionState == ConnectionState.waiting) {
      return CircularProgressIndicator();
    }
    if (snapshot.hasError) {
      return Text('Error: ${snapshot.error}');
    }
    return Text(snapshot.data ?? 'No data');
  },
)

Step-by-Step Fix

  1. 1

    Identify the error

    Look for null widget errors or blank screens from FutureBuilder. The builder must return a non-null Widget for every state.

  2. 2

    Find the cause

    Check if the FutureBuilder builder handles ConnectionState.waiting and error states, not just the data case.

  3. 3

    Apply the fix

    Handle all snapshot states: show a loader for waiting, an error widget for errors, and the data widget when complete.

Got the actual stack trace?

Paste it into our free AI explainer to get the cause and the fix for your specific case — no signup, nothing to install.

Explain my error

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