# Flutter: “Invalid constant value” / “Arguments of a constant creation must be constant expressions”

> Invalid constant value: a const widget or list contains a value only known at runtime. Remove const from the outer widget, or make the value a constant.

Canonical: https://app369.com/fix/flutter-invalid-constant-value/
Last updated: 2026-11-08

The build fails with Error: Invalid constant value (the IDE often says Arguments of a constant creation must be constant expressions, or Invalid constant value). Something marked const, often a widget like const Padding or const Text, contains a variable, a parameter, widget.something or a function call. Everything inside a const expression has to be known at compile time, and const on an outer widget applies to all of its children.

**Short answer**

Find the const nearest above the highlighted value and remove it, or move it down to the children that really are constant. If the value never changes, make it a constant instead (static const or a top-level const). Removing const is safe in ordinary widget code; it only gives up a small rebuild optimization. Where const is required (default parameter values, annotations, const variables), make the value itself constant instead.

## **Why the value isn’t constant, and the fix**

1. 01 ### **A variable inside a const widget**
  > “Either make all of the arguments constant expressions, or remove the const keyword to use the non-constant form of the constructor” [**Dart, const_with_non_constant_argument**](https://dart.dev/tools/diagnostics/const_with_non_constant_argument) const Text(title) fails because title is only known at runtime. The same goes for context, Theme.of(context), MediaQuery.of(context) or widget.something inside a const widget. Drop const from that widget; keep it on siblings that are fully constant.```
// error
const Padding(
  padding: EdgeInsets.all(16),
  child: Text(title),
);

// fixed
Padding(
  padding: const EdgeInsets.all(16),
  child: Text(title),
);
```
2. 02 ### **const applied to a whole list of children** children: const [ … ] makes every child constant. Adding one widget that uses a variable breaks the whole list. Remove const from the list and put it on the individual children that qualify.```
children: [
  const SizedBox(height: 8),
  Text(user.name),
  const Divider(),
],
```
3. 03 ### **A value that should be a constant** A padding or color kept in a final field or a getter can’t be used in const code. If it never changes, declare it const.```
class Spacing {
  static const double page = 16;
}

const EdgeInsets.all(Spacing.page)
```

Checked against the vendor’s docs on November 8, 2026: [Dart diagnostics: const_with_non_constant_argument](https://dart.dev/tools/diagnostics/const_with_non_constant_argument).

## **Rather hand it over?**

Fixed scope, fixed price, paid upfront. The work happens in writing; no call needed.

- [from $450**App Fix Ticket**One reproducible bug in an existing mobile or web app, diagnosed and fixed.**See scope and start**](https://app369.com/fixed-price/flutter-firebase-bug-fix/)
- [from $450**AI-Built App Rescue**A Lovable, Bolt or Cursor app checked end to end in 3 days, then its worst problems fixed at a fixed price.****No issues worth fixing, no charge.**** If the Launch Check finds nothing rated medium or higher, Simon refunds the full $450. You keep the report either way. This applies to the first 10 Launch Checks bought after October 30, 2026.**See scope and start**](https://app369.com/fixed-price/ai-app-rescue/)

Related: [**Flutter “can’t be accessed in an initializer”**](https://app369.com/fix/flutter-instance-member-cant-be-accessed-in-an-initializer/) · [**Flutter “The parameter can’t have a value of null”**](https://app369.com/fix/flutter-parameter-cant-have-a-value-of-null/) · [**Flutter “:app:compileFlutterBuildDebug” failed**](https://app369.com/fix/flutter-execution-failed-for-task-compileflutterbuilddebug/) · [**Flutter “RangeError (index): Invalid value: Not in range”**](https://app369.com/fix/flutter-rangeerror-index-invalid-value-not-in-range/)

Questions

## **More on this error**

<details>

<summary>**Should I just remove every const? **+</summary>

No need. Remove it only where the error points. If you want the analyzer to suggest const again wherever it is valid, enable prefer_const_constructors in analysis_options.yaml; Flutter’s default lints (flutter_lints 5 and later) no longer include it.

</details>

<details>

<summary>**Why did it break after I edited one child? **+</summary>

Because const on a parent covers its children. The parent was valid while every child was constant; the new child made the whole expression non-constant.

</details>

<details>

<summary>**Can you fix it for me? **+</summary>

If one bug is the whole problem, the App Fix Ticket covers it: a written diagnosis first, then the fix. If the app has more going on, the Launch Check is a written check of the whole app. Each issue found is rated critical, high, medium or low, with where it is and how it was confirmed. No issues worth fixing, no charge. If the Launch Check finds nothing rated medium or higher, Simon refunds the full $450. You keep the report either way. This applies to the first 10 Launch Checks bought after October 30, 2026.

</details>

A different error?

## **Describe it and get a written quote**

Send the error and what you were doing. You get a written scope, a fixed price and a timeline; Simon replies by email, usually within one business day.

[**Describe your problem **→](https://app369.com/contact/) [**All fixes**](https://app369.com/fix/)