flutter / flutter/flutter-intellij

Prioritize creating 'final' variables in 'Introduce Variable' refactoring

Open
#8,782 0 comments 0 reactions 0 assignees View on GitHub
P3
Dominant language
Java
Stars
2k
Forks
356
Avg merge
1d 11h
Merged PRs (30d)
27

Description

The 'Introduce Variable' feature currently creates a `var` instead of a `final` variable. It should prioritize `final` when the variable is not reassigned.

**Current Behavior:**

Starting with:
```dart
await Something.initialize(
resourceAttributes: {
'service.environment': config.environment,
}.toAttributes(),
);
```

Using 'Introduce Variable' results in:
```dart
var attributes = {
'service.environment': config.environment,
}.toAttributes();

await Something.initialize(
resourceAttributes: attributes,
);
```

**Desired Behavior:**

It should generate:
```dart
final attributes = {
'service.environment': config.environment,
}.toAttributes();

await Something.initialize(
resourceAttributes: attributes,
);
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.