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

Typing for extra #2315

Closed
moshe5745 opened this issue Oct 15, 2024 · 6 comments
Closed

Typing for extra #2315

moshe5745 opened this issue Oct 15, 2024 · 6 comments
Labels
s: feature This issue indicates a feature request

Comments

@moshe5745
Copy link

Request Statement

Right now there is no typing for extras that could be passed to the request.
For instance, we want to pass some extra data to the interceptor.

Solution Brainstorm

No response

@moshe5745 moshe5745 added the s: feature This issue indicates a feature request label Oct 15, 2024
@AlexV525
Copy link
Member

What does typing help here? You can always safely cast fields by using is.

@moshe5745
Copy link
Author

A generic way to pass data to the interceptor.
Cleaner code I guess.

@moshe5745
Copy link
Author

Guess you're right. This feature is not needed. After I understood the power of is

@AlexV525
Copy link
Member

Also pattern matching is great when destructing extras. See https://dart.dev/language/patterns#validating-incoming-json.

@moshe5745
Copy link
Author

Also pattern matching is great when destructing extras. See https://dart.dev/language/patterns#validating-incoming-json.

Cant pattern match with class on the map object. Too bad...

@moshe5745
Copy link
Author

Also pattern matching is great when destructing extras. See https://dart.dev/language/patterns#validating-incoming-json.

If I have a class like:

class RequestMetadata {
  final int code;

  RequestMetadata({required this.code});
}

I can pattern match it on interceptor only with this

  var code = switch (options.extra) { {"code": int code} => code, _ => "" };

Not a perfect situation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
s: feature This issue indicates a feature request
Projects
None yet
Development

No branches or pull requests

2 participants