Skip to content

class splitting feature similar to C# #54089

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
vinaykumarrock986612 opened this issue Nov 18, 2023 · 2 comments
Closed

class splitting feature similar to C# #54089

vinaykumarrock986612 opened this issue Nov 18, 2023 · 2 comments

Comments

@vinaykumarrock986612
Copy link

In Dart, we currently lack a handy feature that's available in C# called partial. This feature allows developers to split a big class across multiple files, making it more manageable. Although Dart supports splitting libraries using "part" and "part of," handling large classes with lots of logic could be easier with a dedicated class-splitting feature.

When dealing with large classes in Dart, the existing ways of splitting libraries fall short. Additionally, when using mixins, passing variables directly through constructors isn't straightforward. Instead, we need to pass parameters to functions one by one, making the code less straightforward.

Maybe something like partial keyword, to tell Dart that we want to split a class across multiple files. This would be super useful for classes with a ton of logic, letting developers spread out the code in different files while still keeping things neat and readable.

Example:

// File: my_class_part1.dart
partial class MyClass {
  void method1() {
    // Implementation of method1
  }
}

// File: my_class_part2.dart
partial class MyClass {
  void method2() {
    // Implementation of method2
  }
}

// File: my_class.dart
class MyClass {
  // A basic class definition, just holding things together
}

Helps keep large classes organized.
Makes it easier for a team to work on different parts of a class independently.
Improves code readability and maintenance.

@halildurmus
Copy link
Contributor

Duplicate of dart-lang/language#252

@vsmenon
Copy link
Member

vsmenon commented Nov 18, 2023

Thanks, closing as dup.

@vsmenon vsmenon closed this as completed Nov 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants