> ## Documentation Index
> Fetch the complete documentation index at: https://docs.syntblaze.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Dart Named Parameter

Named parameters are function arguments explicitly bound to a parameter identifier at the call site, rather than relying on their ordinal position in the argument list. In Dart, they are declared by enclosing the parameter definitions within curly braces `{}` in the function signature.

## Syntax and Declaration

To define named parameters, place them inside `{}` at the end of the parameter list. At the call site, they are invoked using the `parameterName: value` syntax.

```dart theme={"dark"}
// Declaration
void configure({String? host, int port = 80}) {
  // Function body
}

void main() {
  // Invocation
  configure(port: 443, host: '127.0.0.1');
}
```

## Technical Characteristics

**1. Optionality and Nullability**
By default, all named parameters are optional. Because they can be omitted during invocation, Dart's sound null safety requires that an optional named parameter must either be declared as a nullable type (using the `?` suffix) or be assigned a default value.

**2. Default Values**
Default values are assigned using the `=` operator in the function signature. The assigned default value must be a compile-time constant.

```dart theme={"dark"}
void setFlags({bool isVerbose = false, String? logPath}) {}
```

**3. The `required` Modifier**
To mandate that a caller provides a specific named parameter, prefix the parameter declaration with the `required` keyword. A `required` named parameter bypasses the default optionality rule, meaning it does not need to be nullable or possess a default value, as the analyzer guarantees its presence at compile time.

```dart theme={"dark"}
void initialize({required String apiKey, required int environmentId}) {}
```

**4. Ordering and Interleaving**
At the call site, named arguments can be passed in any arbitrary order, completely independent of their declaration order in the function signature.

Furthermore, as of Dart 2.17, named arguments can be interleaved with positional arguments at the call site, provided the positional arguments maintain their strict ordinal sequence.

```dart theme={"dark"}
void processData(int id, String payload, {required bool encrypt, int retries = 3}) {}

void main() {
  // Valid: Named arguments placed after positional arguments
  processData(101, 'data', encrypt: true, retries: 5);

  // Valid: Named arguments interleaved with positional arguments (Dart 2.17+)
  processData(101, encrypt: true, 'data', retries: 5);
  
  // Valid: Arbitrary ordering of the named arguments themselves
  processData(101, 'data', retries: 5, encrypt: true);
}
```

<div
  style={{ 
display: "flex", 
justifyContent: "space-between", 
alignItems: "center", 
maxWidth: "754px", 
padding: "1rem 0",
marginBottom: "24px"
}}
>
  <span style={{ fontWeight: "bold", fontSize: "1.25rem", color: "var(--tw-prose-headings)", fontFamily: "Inter, ui-sans-serif, system-ui, sans-serif" }}>Tired of Poor Dart Skills? Fix That With Deep Grasping!</span>

  <a
    href="https://syntblaze.com"
    target="_blank"
    style={{ 
  marginLeft: "24px",
  textDecoration: "none", 
  backgroundColor: "#007AFF",
  color: "#ffffff", 
  padding: "6px 16px", 
  borderRadius: "16px",
  fontSize: "0.9rem",
  fontWeight: "600",
  textAlign: "center",
  transition: "background-color 0.2s ease"
}}
  >
    Learn More
  </a>
</div>

<div style={{ display: "flex", gap: "12px", flexWrap: "wrap" }}>
  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/skill-tracking.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=b9b0305c93bb501c9e767b5c76c88835" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/skill-tracking.png" />

  <img src="https://mintcdn.com/syntblazellc/23tyuOzaWS88qFlc/images/nuggets.png?fit=max&auto=format&n=23tyuOzaWS88qFlc&q=85&s=c86c80197299762989e9b882419b2109" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/nuggets.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/bite-sized-exercises.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=a65f9a38c37ff28ab73ed783c53c60e3" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/bite-sized-exercises.png" />
</div>

<div style={{ display: "flex", gap: "12px", flexWrap: "wrap", marginTop: "12px" }}>
  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/mastery-chain.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=748a1763454713e679260fbb95f154a2" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/mastery-chain.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/element-previews.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=242f61448ff5dd6deaaab2dccc13b507" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/element-previews.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/element-explanations.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=cf0fc1c31f9cd0fc26716781be05fbc9" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/element-explanations.png" />
</div>
