Flutter / Dart errors

Flutter and Dart errors — layout overflows, state lifecycle, null safety and build problems.

CodeErrorWhat it means
setState() called after dispose() Flutter: setState() called after dispose(): _MyState#1a2b3 (lifecycle state: defunct, not mounted) An async callback (network, timer, stream) finished after the widget was removed and then called setState.
MissingPluginException: No implementation found for method Flutter: MissingPluginException(No implementation found for method getAll on channel plugins.flutter.io/shared_preferences) Dart called a plugin's native method but the native side is not registered, usually because the app was not f…
SocketException: Failed host lookup Flutter: Unhandled Exception: SocketException: Failed host lookup: 'api.example.com' (OS Error: No address associated with hostname, errno = 7) The app could not resolve or reach the server: no internet, wrong host name, DNS failure, or missing network…
Looking up a deactivated widget's ancestor is unsafe Flutter: Looking up a deactivated widget's ancestor is unsafe. At this point the state of the widget's element tree is no longer stable You used a `BuildContext` after its widget was removed from the tree — typically after an `await` when the us…
A RenderFlex overflowed Flutter: A RenderFlex overflowed by x pixels on the right/bottom A Row or Column’s children need more space than available, so Flutter draws the yellow-black overflow stripes.
A Timer is still pending even after the widget tree was disposed Flutter test: A Timer is still pending even after the widget tree was disposed A widget test finished while a `Timer` or delayed `Future` was still scheduled.
Android license status unknown / licenses not accepted flutter doctor: Android license status unknown. Run `flutter doctor --android-licenses` to accept the SDK licenses The Android SDK licenses have not been accepted, so builds cannot download or use SDK components.
Unsupported class file major version (Gradle / Java) Android Gradle: Execution failed — Unsupported class file major version 65 / Android Gradle plugin requires Java 17 to run Gradle or the Android Gradle plugin is running on a Java version it does not support.
The argument type can't be assigned to the parameter type Dart: The argument type 'String?' can't be assigned to the parameter type 'String' You passed a value whose type does not match what the function parameter requires.
Error: Could not find the correct Provider Flutter: Error: Could not find the correct Provider<CartModel> above this Consumer<CartModel> Widget A widget asked Provider for an object that is not above it in the widget tree.
Module 'x' not found (iOS build) Xcode: Module 'firebase_core' not found — flutter build ios fails after adding a plugin The iOS project cannot find a CocoaPods module, usually because Pods are missing, outdated, or the workspace…
FormatException: Unexpected character Dart: FormatException: Unexpected character (at character 1) <!DOCTYPE html> — jsonDecode of an HTML page `jsonDecode` received something that is not JSON, commonly an HTML error page, an empty string, or a plain-te…
HandshakeException: CERTIFICATE_VERIFY_FAILED Dart: HandshakeException: Handshake error in client (OS Error: CERTIFICATE_VERIFY_FAILED: unable to get local issuer certificate) The app refused the server's TLS certificate because it is self-signed, expired, missing intermediates, or th…
Cleartext HTTP traffic not permitted Flutter (Android): java.io.IOException: Cleartext HTTP traffic to api.example.com not permitted Android 9+ blocks plain `http://` requests by default; the app must use HTTPS or explicitly allow cleartext f…
NetworkImageLoadException: HTTP request failed, statusCode: 404 Flutter: Exception caught by image resource service — NetworkImageLoadException: HTTP request failed, statusCode: 404, https://example.com/a.png `Image.network` could not download the image (bad URL, status error, or blocked by CORS on web).
RenderBox was not laid out Flutter: RenderBox was not laid out: RenderFlex#a1b2c relayoutBoundary=up2 NEEDS-PAINT — Failed assertion: 'hasSize' A widget was asked for its size or painted before layout finished, usually because a parent gave it unbounded…
There are multiple heroes that share the same tag Flutter: There are multiple heroes that share the same tag within a subtree Two `Hero` widgets with the same tag exist on one screen during a route transition.
The current Dart SDK version is x; package requires SDK >= y Dart pub: The current Dart SDK version is 2.19.0. Because app requires SDK version >=3.0.0 <4.0.0, version solving failed A package (or your own pubspec) requires a newer Dart SDK than the one your Flutter installation provides.
LateInitializationError: Field has not been initialized Dart: LateInitializationError: Field 'controller' has not been initialized A `late` variable was read before it was assigned.
type 'Null' is not a subtype of type 'String' Dart: type 'Null' is not a subtype of type 'String' in type cast A value that was `null` at runtime was cast or used as a non-nullable type, most often when parsing JSON.
Null check operator used on a null value Dart/Flutter: Null check operator used on a null value The ! operator was applied to a variable that was null at runtime.
Expected: exactly one matching candidate, Actual: found 0 widgets Flutter test: Expected: exactly one matching candidate Actual: _TextFinder:<Found 0 widgets with text "Hello"> A widget test looked for a widget that is not currently in the tree.
A Ticker was active when the State was disposed Flutter: _HomeState#abc(ticker active) was disposed with an active Ticker. State.dispose() implementations must call dispose() on all their AnimationControllers An `AnimationController` was still running when its `State` was disposed, because `dispose()` did not release…
BoxConstraints forces an infinite width Flutter: BoxConstraints forces an infinite width. These invalid constraints were provided to RenderStack's layout() function (TextField in a Row) A widget that needs a finite width, like a `TextField` or `Container` with no size, was placed where the pare…
Gradle task assembleDebug failed with exit code 1 Flutter: Exception: Gradle task assembleDebug failed with exit code 1 `flutter run` / `flutter build apk` stopped because the Gradle build failed; the real cause is printed above…
Incorrect use of ParentDataWidget Flutter: Incorrect use of ParentDataWidget. The ParentDataWidget Expanded(flex: 1) wants to apply ParentData of type FlexParentData to a RenderObject A widget like `Expanded`, `Flexible`, `Positioned` or `TableCell` was placed under a parent that does not sup…
No Material widget found Flutter: No Material widget found. TextField widgets require a Material widget ancestor A Material-design widget (TextField, ListTile, InkWell, Chip) was placed outside a `Scaffold`, `Material` or…
PlatformException(sign_in_failed, ApiException: 10) Flutter: PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null, null) Google Sign-In failed on Android because the app's SHA-1 fingerprint or package name is not registered for th…
setState() or markNeedsBuild() called during build Flutter: setState() or markNeedsBuild() called during build. This widget cannot be marked as needing to build because the framework is already in the process of building widgets State was changed while Flutter was building widgets, for example calling `setState` or a notifier from insid…
Vertical viewport was given unbounded height Flutter: Vertical viewport was given unbounded height. Viewports expand in the scrolling direction to fill their container A scrollable (ListView, GridView) sits inside a parent that does not limit its height, so it tries to be infi…
App Transport Security has blocked a cleartext HTTP load iOS: The resource could not be loaded because the App Transport Security policy requires the use of a secure connection (NSURLErrorDomain -1022) iOS blocks plain HTTP connections by default unless the domain is allowed in `Info.plist`.
Dependency requires compileSdk 34 or later Android Gradle: Execution failed for task ':app:checkDebugAarMetadata'. Dependency requires libraries and applications that depend on it to compile against version 34 or later of the Android APIs A dependency was built against a newer Android API than your project's `compileSdk`.
Bad state: Stream has already been listened to Dart: Bad state: Stream has already been listened to A single-subscription stream was listened to twice, for instance by two `StreamBuilder`s or after a rebuild.
Non-nullable instance field must be initialized Dart: Non-nullable instance field 'name' must be initialized. Try adding an initializer expression, or a generative constructor that initializes it, or mark it 'late' With null safety every non-nullable field needs a value by the end of construction.
type '_InternalLinkedHashMap' is not a subtype of type 'List<dynamic>' Dart: type '_InternalLinkedHashMap<String, dynamic>' is not a subtype of type 'List<dynamic>' in type cast JSON decoded to a Map but your code expected a List (or the other way round).
No connected devices / device not found flutter run: No connected devices found; check 'flutter doctor'. Expected at least one device Flutter cannot see any emulator, simulator, browser or phone to run on.
Navigator operation requested with a context that does not include a Navigator Flutter: Navigator operation requested with a context that does not include a Navigator `Navigator.push/pop` was called with a context above the `MaterialApp`, so no Navigator exists in the lookup…
Scaffold.of() called with a context that does not contain a Scaffold Flutter: Scaffold.of() called with a context that does not contain a Scaffold You called `Scaffold.of(context)` (or `ScaffoldMessenger`) using the same `BuildContext` that created the Sca…
No profiles for 'x' were found Xcode: No profiles for 'com.example.app' were found: Xcode couldn't find any iOS App Development provisioning profiles matching Xcode could not sign the app because no provisioning profile or development team is set for the bundle identi…
minSdkVersion cannot be smaller than the library's Android Gradle: uses-sdk:minSdkVersion 16 cannot be smaller than version 21 declared in library [:firebase_auth] A plugin requires a higher Android minimum SDK than your app declares.
version solving failed (pub get) Dart pub: Because app depends on intl ^0.19.0 and flutter_localizations from sdk depends on intl 0.18.1, version solving failed `flutter pub get` cannot find a set of package versions that satisfy every dependency's constraints.
The getter/method isn't defined for the type Dart: The getter 'name' isn't defined for the type 'User' / The method 'foo' isn't defined for the class The analyzer cannot find that property or method on the object's static type.
cmdline-tools component is missing flutter doctor: Android SDK is missing command-line tools; download from https://goo.gl/XxQghQ — cmdline-tools component is missing The Android SDK Command-line Tools package is not installed, so Flutter cannot run `sdkmanager` or accept lic…
CocoaPods: pod install failed / not installed Flutter iOS: Error running pod install — CocoaPods not installed or out of date / [!] CocoaPods could not find compatible versions for pod The iOS build cannot install its native dependencies because CocoaPods is missing, outdated or a pod's versio…
No Firebase App '[DEFAULT]' has been created Flutter: [core/no-app] No Firebase App '[DEFAULT]' has been created - call Firebase.initializeApp() A Firebase service was used before `Firebase.initializeApp()` ran and completed.
dependOnInheritedWidgetOfExactType called before initState completed Flutter: dependOnInheritedWidgetOfExactType<_InheritedTheme>() or dependOnInheritedElement() was called before _HomeState.initState() completed `Theme.of(context)`, `MediaQuery.of(context)` or `Provider.of(context)` was used in `initState`, where inheri…
MediaQuery.of() called with a context that does not contain a MediaQuery Flutter: MediaQuery.of() called with a context that does not contain a MediaQuery Code asked for screen size or theme data using a context that has no MediaQuery ancestor, usually above or ou…
Bad state: No element Dart: Bad state: No element — .first, .last or .single on an empty list You called `.first`, `.last`, `.single` or `.reduce` on an empty collection.
Illegal argument in isolate message: object is unsendable Dart: Invalid argument(s): Illegal argument in isolate message: object is unsendable - Library:'dart:async' Class: _Future@4048458 You tried to send an object (closure, Future, socket, platform object) to another isolate that cannot be copi…
RangeError (index): Invalid value Dart: RangeError (index): Invalid value: Valid value range is empty: 0 A list or string was indexed outside its bounds, often an empty list or an off-by-one in `itemBuilder`.
Error: Couldn't resolve the package Dart: Error: Couldn't resolve the package 'x' in 'package:x/x.dart' Code imports a package that is not in `pubspec.yaml` or `pub get` has not been run since adding it.
The named parameter is required, but there's no corresponding argument Dart: The named parameter 'key' is required, but there's no corresponding argument A constructor or function marked `required` for a parameter was called without it.
The property/method can't be unconditionally accessed because the receiver can be null Dart: The property 'length' can't be unconditionally accessed because the receiver can be 'null' With null safety you used `.` on a nullable value; Dart requires a null check first.