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

[native_assets_cli] Explore using extension types #997

Closed
Tracked by #882
dcharkes opened this issue Mar 12, 2024 · 1 comment
Closed
Tracked by #882

[native_assets_cli] Explore using extension types #997

dcharkes opened this issue Mar 12, 2024 · 1 comment

Comments

@dcharkes
Copy link
Collaborator

Filing an issue to explore this separately.

Consider if it's easier to have just one class with public API and private API, and then an extension type wrapper that exposes public accessors for the private API, and only expose that extension type to the tools that need access to private API.

That is:

final class Architecture {
  final String _dartPlatform;
  // ...
}

extension type ArchitectureModel(Architecture _) implements Architecture {
  String get dartPlatform => _._dartPlatform;
  // Other private API exposed.
}

That will still prevent casual users, who can't import ArchitectureModel directly with reaching into src/, from accessing .dartPlaform dynamically.

#946 (comment)

Pro:

  • This would avoid having two class hierarchies and casts everywhere.

Con:

  • None of the private members can be used for interface calls, so we'll have a bunch of switches.
@dcharkes
Copy link
Collaborator Author

Notes with discussion from @mosuem

Using interface and implementation seems more well established and easier to understand than extension types.

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

1 participant