Skip to content

[native_assets_cli] Explore using extension types  #997

@dcharkes

Description

@dcharkes

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions