Closed codakkk closed 3 months ago
Hi @codakkk the only way is to use part files https://medium.com/@TakRutvik/part-in-dart-d78f91f66f91
check the issue https://github.com/artflutter/reactive_forms_generator/issues/86
Hi @codakkk the only way is to use part files https://medium.com/@TakRutvik/part-in-dart-d78f91f66f91
check the issue https://github.com/artflutter/reactive_forms_generator/issues/86
Well, the problem relies on the fact that I cannot use part files like you saying, because I'm using freezed, hence part is already used. Can you provide me an example based on my code? And why is the AddressForm generated in the Person and Garage form instead of in his own file?
Try to use them. Freezed does not prevent you from using parts. You can combine the file from infinite amount of parts
Try to use them. Freezed does not prevent you from using parts. You can combine the file from infinite amount of parts
Still this doesn't make any sense to me. Why I have to use part files when shared models could create their own classess separately?
Anyway, no, I'm not able to use part files, because it says that:
Expected this library to be part of 'package:ncc/forms/guide/guide.dart', not 'package:ncc/forms/address/address.g.dart'. Try including a different part, or changing the name of the library in the part's part-of directive
Try to use them. Freezed does not prevent you from using parts. You can combine the file from infinite amount of parts
Still this doesn't make any sense to me. Why I have to use part files when shared models could create their own classess separately?
Anyway, no, I'm not able to use part files, because it says that:
`Expected this library to be part of 'package:ncc/forms/guide/guide.dart', not 'package:ncc/forms/address/address.g.dart'.
Try including a different part, or changing the name of the library in the part's part-of directive`
Could you provide a reproducible sample?
Why I have to use part files
The answer unfortunately is very simple. Cause we have no other options for now. All classes should be in one file. It could be on large file or several partitioned files.
As far as we have those options I do not plan to invest in alternative solutions
I do not even know if any other solutions are possible
Try to use them. Freezed does not prevent you from using parts. You can combine the file from infinite amount of parts
Still this doesn't make any sense to me. Why I have to use part files when shared models could create their own classess separately? Anyway, no, I'm not able to use part files, because it says that:
Expected this library to be part of 'package:ncc/forms/guide/guide.dart', not 'package:ncc/forms/address/address.g.dart'. Try including a different part, or changing the name of the library in the part's part-of directive
Could you provide a reproducible sample?
Exactly the one I wrote on the issue!
Why I have to use part files
The answer unfortunately is very simple. Cause we have no other options for now. All classes should be in one file. It could be on large file or several partitioned files.
As far as we have those options I do not plan to invest in alternative solutions
I do not even know if any other solutions are possible
Okay, makes sense. Thank you. I'll refactor my forms and make sure they're part of the same file. This seems the only way to make it work correctly
Hi @codakkk! Your issue has been closed. If we were helpful don't forget to star the repo.
Please check our reactive_forms_widget package
We would appreciate sponsorship subscription or one time donation https://github.com/sponsors/artflutter
I'm having problems using shared models. I have an "Address" model, which is shared between all the forms that requires an address. Take as an example the form "Person" and "Garage". The problem occurrs when both forms try to use the "Address" model. This is the error:
The name 'AddressForm' is defined in the libraries 'person/person.dart' and 'garage/garage.dart'. Try removing the export of one of the libraries, or explicitly hiding the name in one of the export directives.
Take as an example this snippet:
address.dart
garage.dart
person.dart
What I do expect is that both
Person
andGarage
share the sameAddressForm
class because it's a model and not an instance. Instead it's creating a newAddressForm
class for each occurrence, thus creating this problem. Looking at the code ofAddressForm
there's no reason to have it generated inside the form file (Person or Garage in my example)