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

[FEATURE] Is it possible to add a base_model option? #782

Open
HonQii opened this issue Nov 26, 2024 · 0 comments
Open

[FEATURE] Is it possible to add a base_model option? #782

HonQii opened this issue Nov 26, 2024 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@HonQii
Copy link

HonQii commented Nov 26, 2024

All of my server's return structures are

Result {
  final int? code; final String?
  final DataType? data; final String?
  final String? msg;
 }

So I want all generated Models to inherit from some abstract so that I can easily access the code and msg attributes in order to handle error messages consistently.

Describe the solution you'd like
I want to be able to pass in a path in build.yaml via base_model, e.g. lib/template/base_model.dart. base_model.dart defines a class of the same name

abstract class BaseModel {
  int? code;
  String? msg;
}

Then all generated Models inherit from this class, so I can process all request results uniformly regardless of their type!

@HonQii HonQii added the enhancement New feature or request label Nov 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants