Errors/Flutter

Common Flutter Errors

Flutter and Dart errors including RenderFlex overflow, setState after dispose, null safety issues, and navigation errors.

60 errors documented with step-by-step fixes

A RenderFlex overflowed by pixels on the right

A RenderFlex overflowed by 42 pixels on the right.

A Row or Column child is too large for the available space.

A RenderFlex overflowed by pixels on the bottom

A RenderFlex overflowed by 120 pixels on the bottom.

A Column has more children than the screen can fit vertically.

setState() called after dispose()

setState() called after dispose(): _MyWidgetState#abcde(lifecycle state: defunct, not mounted)

You called setState on a widget that has already been removed from the widget tree.

Null check operator used on a null value

Null check operator used on a null value

You used the ! operator on a variable that was null at runtime.

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

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

A null value was assigned or passed where a non-nullable String was expected.

The method was called on null

NoSuchMethodError: The method 'toString' was called on null.

You tried to call a method on a variable that was null.

Navigator operation with context that does not include a Navigator

Navigator operation requested with a context that does not include a Navigator.

The BuildContext used for navigation does not have a Navigator ancestor in the widget tree.

Scaffold.of() called with context that does not contain a Scaffold

Scaffold.of() called with a context that does not contain a Scaffold.

The BuildContext used does not have a Scaffold ancestor in the widget tree.

The getter 'length' was called on null

NoSuchMethodError: The getter 'length' was called on null.

You tried to access a property on a null object.

No Material widget found

No Material widget found. TextField widgets require a Material widget ancestor.

A Material Design widget is used without a Material ancestor like Scaffold or Material.

LateInitializationError: Field has not been initialized

LateInitializationError: Field 'controller' has not been initialized.

A field declared with late was accessed before it was assigned a value.

Bad state: No element

Bad state: No element

You called .first, .last, or .single on an empty iterable.

Concurrent modification during iteration

Concurrent modification during iteration: Instance of '_GrowableList'.

You modified a list while iterating over it with a for-in loop.

MissingPluginException

MissingPluginException(No implementation found for method X on channel Y)

A platform channel method has no native implementation registered.

PlatformException

PlatformException(error, message, null, null)

A platform-specific operation (Android/iOS) failed with a native error.

Looking up a deactivated widget's ancestor is unsafe

Looking up a deactivated widget's ancestor is unsafe.

You used a BuildContext after its widget was removed from the tree.

Vertical viewport was given unbounded height

Vertical viewport was given unbounded height.

A ListView or scrollable widget was placed inside a Column without bounded height.

RangeError (index): Invalid value

RangeError (index): Invalid value: Not in inclusive range 0..2: 3

You tried to access a list index that does not exist.

type 'int' is not a subtype of type 'String'

type 'int' is not a subtype of type 'String'

A value of type int was used where a String was expected.

type 'String' is not a subtype of type 'int'

type 'String' is not a subtype of type 'int'

A String value was used where an int was expected.

Duplicate GlobalKey detected in widget tree

Duplicate GlobalKey detected in widget tree.

Two widgets in the tree share the same GlobalKey, which must be unique.

Unhandled Exception: Future not completed

Unhandled Exception: Exception: Something went wrong

An async Future threw an exception that was not caught.

setState() or markNeedsBuild() called during build

setState() or markNeedsBuild() called during build.

You called setState inside the build method, which triggers an infinite rebuild cycle.

BoxConstraints forces an infinite width/height

BoxConstraints forces an infinite width.

A widget received infinite constraints but requires a finite size.

Unsupported operation on an unmodifiable list

Unsupported operation: Cannot add to an unmodifiable list

You tried to modify a list that is fixed-length or unmodifiable.

SocketException: Connection refused

SocketException: OS Error: Connection refused, errno = 111

The app could not connect to the server, usually due to network issues or wrong URL.

type 'List<dynamic>' is not a subtype of type 'List<String>'

type 'List<dynamic>' is not a subtype of type 'List<String>'

A List<dynamic> from JSON was assigned to a typed List<String> variable.

FormatException: Invalid number

FormatException: Invalid radix-10 number (at character 1)

You tried to parse a string that is not a valid number.

Multiple widgets used the same GlobalKey

Multiple widgets used the same GlobalKey.

A GlobalKey was assigned to more than one widget simultaneously.

No MediaQuery widget ancestor found

No MediaQuery widget ancestor found.

MediaQuery.of(context) was called without a MaterialApp or WidgetsApp ancestor.

Incorrect use of ParentDataWidget

Incorrect use of ParentDataWidget. Expanded widgets must be placed inside Flex widgets.

An Expanded or Flexible widget was used outside of a Row, Column, or Flex.

No State found for widget

No State found for _MyWidget. Did you call createState()?

Flutter could not find the State object for a StatefulWidget.

RenderBox was not laid out: hasSize is false

'package:flutter/src/rendering/box.dart': Failed assertion: line 1940 pos 12: 'hasSize'

A RenderBox was accessed for its size before layout was completed.

dependOnInheritedWidgetOfExactType returned null

dependOnInheritedWidgetOfExactType<MyInheritedWidget>() was called but no MyInheritedWidget ancestor was found.

An InheritedWidget was requested but does not exist in the ancestor widget tree.

Bottom overflowed by pixels when keyboard appears

A RenderFlex overflowed by 200 pixels on the bottom.

The soft keyboard pushed content up causing overflow in a non-scrollable layout.

Unable to load asset image

Unable to load asset: assets/images/logo.png

The asset file path is wrong or not declared in pubspec.yaml.

SocketException: No address associated with hostname

SocketException: Failed host lookup: 'api.example.com' (OS Error: No address associated with hostname, errno = 7)

DNS resolution failed, usually because there is no internet connection.

ProviderNotFoundException: Could not find Provider

ProviderNotFoundException: Error: Could not find the correct Provider<MyModel> above this Widget.

A Provider was requested with context but it does not exist above the widget in the tree.

Bad state: Cannot read providers when not initialized

Bad state: No ProviderScope found. Did you forget to add ProviderScope at the root of your app?

Riverpod requires a ProviderScope at the root of the app to function.

BlocProvider.of() called with wrong context

BlocProvider.of() called with a context that does not contain a Bloc of type MyBloc.

The context used to find the Bloc does not have a BlocProvider ancestor for that Bloc type.

FutureBuilder snapshot has no data

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

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

Bad state: Stream has already been listened to

Bad state: Stream has already been listened to.

A single-subscription Stream was listened to more than once.

Stack overflow caused by circular widget dependency

Stack Overflow

A widget's build method creates an infinite loop by including itself.

InputDecoration does not match InputDecorationTheme

A InputDecoration was provided to a TextField that does not match the InputDecorationTheme.

The InputDecoration has properties that conflict with the theme's InputDecorationTheme.

A non-null value must be returned from async function

A value of type 'Null' can't be returned from the function 'fetchData' because it has a return type of 'Future<String>'.

An async function with a non-nullable return type does not return a value on all code paths.

Cannot hit test a RenderBox with no size

Cannot hit test a render box with no size.

A widget with zero size was tapped, typically due to a missing layout constraint.

AnimationController not disposed properly

AnimationController.dispose() called more than once.

An AnimationController was disposed multiple times or used after disposal.

There are multiple heroes that share the same tag

There are multiple heroes that share the same tag within a subtree.

Two Hero widgets on the same screen have the same tag value.

Text overflows its container boundary

A RenderFlex overflowed by 50 pixels on the right.

A Text widget exceeds its parent's width without overflow handling.

GestureDetector conflicts with scroll gestures

The gesture detector does not receive tap events inside a scrollable widget.

GestureDetector inside a scrollable widget loses tap events to the scroll gesture.

Invalid constant value in const constructor

Invalid constant value.

A non-constant value was used in a const context.

setState called from outside State class

Undefined name 'setState'.

setState is only available inside a State class of a StatefulWidget.

Timer callback called after widget dispose

setState() called after dispose(): Timer callback still active

A Timer was not cancelled in dispose(), causing callbacks after the widget is removed.

Could not find a generator for route RouteSettings

Could not find a generator for route RouteSettings("/details", null) in the _WidgetsAppState.

A named route was pushed that is not defined in the app's route table.

FormatException: Unexpected character in JSON

FormatException: Unexpected character (at character 1)

jsonDecode received a string that is not valid JSON.

ScrollController not attached to any scroll views

ScrollController not attached to any scroll views.

You accessed a ScrollController's properties before attaching it to a scrollable widget.

TextEditingController used after being disposed

A TextEditingController was used after being disposed.

You accessed a TextEditingController after calling dispose on it.

Do not use BuildContext across async gaps

Don't use 'BuildContext' across async gaps. (use_build_context_synchronously)

A lint warning that BuildContext was used after an await, where the widget may no longer exist.

Widget test fails because pump was not called

The following assertion was thrown during a scheduler callback: There are no more frames to dispose.

In widget tests, you must call tester.pump() or tester.pumpAndSettle() after interactions.

No Directionality widget found

No Directionality widget found.

A widget that needs text direction has no Directionality ancestor.

Bugsly catches Flutter errors automatically

AI-powered error tracking that explains what went wrong and suggests fixes. Set up in 2 minutes.

Get Started Free