Skip to content

Allow multiple class{} blocks for same class if in same file (so we can have constructors in part files) #3173

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

Closed
gisborne opened this issue Jun 28, 2023 · 2 comments
Labels
feature Proposed language feature that solves one or more problems state-duplicate This issue or pull request already exists

Comments

@gisborne
Copy link

Many folks try to maintain short files. I often use Dart's part feature for this.

But if I have what would otherwise be a large class, I am limited in my ability to do this. In particular, all constructors must be in the main file.

So if I have multiple, complex constructors, my file gets big and I have no real way to mitigate this.

It would be useful if I can declare the components of a class in multiple files. The simple way to do this is to have multiple declarations of the same class in the same "file".

This sort of thing.

//foo.dart

part "foo_constructor.dart";

class Foo{
  Foo._(){}
}
//foo_constructor.dart

part_of "foo.dart";

class Foo{
  Foo() : Foo._();
}
@gisborne gisborne added the feature Proposed language feature that solves one or more problems label Jun 28, 2023
@mateusfccp
Copy link
Contributor

Isn't this basically the same as augmentation libraries?

@lrhn
Copy link
Member

lrhn commented Jun 28, 2023

Or partial classes (#252), which augmentations is intended as a solution for.

Closing as duplicate of either.

@lrhn lrhn closed this as completed Jun 28, 2023
@lrhn lrhn added the state-duplicate This issue or pull request already exists label Jun 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Proposed language feature that solves one or more problems state-duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

3 participants