Skip to content

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

Closed
@gisborne

Description

@gisborne

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._();
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureProposed language feature that solves one or more problemsstate-duplicateThis issue or pull request already exists

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions