Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add configurable line length section #6371

Merged
merged 8 commits into from
Jan 31, 2025
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions src/content/tools/analysis.md
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,29 @@ analyzer:
dead_code: info
```

## Configuring formatter page width
parlough marked this conversation as resolved.
Show resolved Hide resolved

When you run [`dart format`][], the formatter defaults to
80 character line length or shorter.
If you'd like to configure the line length for your project,
you can add a top-level `formatter` section to the `analysis_options.yaml` file,
like so:

```yaml
MaryaBelanger marked this conversation as resolved.
Show resolved Hide resolved
formatter:
page_width: 123
```

With the analysis options file typically at the root,
the configured line length will apply to everything in the package.

You can also configure individual files' line length,
overriding the analysis options file,
with a marker comment at the top of the file before any other code:

```dart
// dart format width=123
```

## Resources

Expand All @@ -603,3 +626,4 @@ Use the following resources to learn more about static analysis in Dart:
[dead_code]: /tools/diagnostic-messages#dead_code
[disable individual rules]: #disabling-individual-rules
[Effective Dart]: /effective-dart
[`dart format`]: /tools/dart-format
Loading