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

Special-case decorator-style methods #382

Closed
nex3 opened this issue Jul 6, 2015 · 3 comments
Closed

Special-case decorator-style methods #382

nex3 opened this issue Jul 6, 2015 · 3 comments

Comments

@nex3
Copy link
Member

nex3 commented Jul 6, 2015

I use the following pattern occasionally to simulate decorators; that is, to wrap the body of a method in some block or another to modify its behavior. It avoids extra indentation and looks nice, without being too complex:

Future doThing() => pool.withResource(() {
  // ...
});

Currently, the formatter formats this like so:

Future doThing() => pool.withResource(() {
      // ...
    });

It would be nice if it recognized the specific pattern of a => method with a block-format body and indented it like a normal method body.

@seaneagan
Copy link

per the style guide

@munificent
Copy link
Member

You're right, @seaneagan, though we also need to tweak the style guide a bit in light of the formatter's more complex handling of nested function arguments. The original style guide rules just produce really nasty output in some cases.

Relevant style guide bug: dart-archive/www.dartlang.org#1397

@munificent
Copy link
Member

The forthcoming tall style supports exactly this. You get:

Future doThing() => pool.withResource(() {
  // ...
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants