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

Use named arguments for options classes and make all fields private #61

Closed
tiholic opened this issue Nov 9, 2020 · 0 comments
Closed
Assignees

Comments

@tiholic
Copy link
Contributor

tiholic commented Nov 9, 2020

Python allows kwargs to pass all the possible options to create a ClientOptions object. With flutter, we need to have properties of all such objects (ClientOptions, ChannelOptions, etc) as public and SDK users need to instantiate the class and then set these properties.

So, as per the current implementation:

//usage 1
final options = ClientOptions();
options.environment = 'sandbox';
options.logLevel = LogLevel.verbose;
//usage 2
final options = ClientOptions()
    ..environment = 'sandbox'
    ..logLevel = LogLevel.verbose;

It would be more intuitive to dart developers if we can consider changing the constructors to use named arguments and make all the fields as private.

With the named arguments approach, the usage would be:

final options = ClientOptions(
  environment: 'sandbox',
  logLevel: LogLevel.verbose,
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants