artflutter / reactive_forms_generator

Other
82 stars 22 forks source link

Generate file in folder #164

Closed airychkov closed 3 weeks ago

airychkov commented 1 month ago

Hello

Could you please add option to generate in specified folder? Like freezed.

from build.yaml

freezed: enabled: true options: build_extensions: 'lib/{{path}}/{{file}}.dart': 'lib/{{path}}/generated/{{file}}.freezed.dart'

vasilich6107 commented 1 month ago

Hey Probably this is not a freezed feature but the feature of build runner https://stackoverflow.com/questions/68190081/is-there-a-way-to-put-the-generated-files-in-a-separate-folder-in-flutter

https://github.com/rrousselGit/freezed/issues/633#issuecomment-1100594864

https://github.com/dart-lang/source_gen/blob/master/source_gen/README.md#generating-files-in-different-directories

airychkov commented 1 month ago

I did config like in guides

reactive_forms_generator: enabled: true options: build_extensions: 'lib/{{path}}/{{file}}.dart': 'lib/{{path}}/generated/{{file}}.gform.dart'

add in file part 'generated/xxx.gform.dart'; and get message: xxx.gform.dart must be included as a part directive in the input library with: part 'xxx.gform.dart';

your code for builder is different from freezed

and in your build.yaml different extention build_extensions: { '.dart': [ '.gr.dart' ] }. Not gform.

vasilich6107 commented 1 month ago

could you check if reactive_forms_generator 5.0.2 will help you

airychkov commented 1 month ago

I copy-past form freezed builder.dart I don't know how it's work. =) I'm new in dart/flutter It's working as I want.

Builder reactiveFormsGenerator(BuilderOptions options) { return PartBuilder( [ReactiveFormsGenerator()], formatOutput: options.config['format'] == false ? (str) => str : null, '.gform.dart', header: ''' // coverage:ignore-file // GENERATED CODE - DO NOT MODIFY BY HAND // ignore_for_file: type=lint ''', options: options, ); // return PartBuilder( // [const ReactiveFormsGenerator()],

// '.gform.dart', // header: ''' // // coverage:ignore-file // // GENERATED CODE - DO NOT MODIFY BY HAND // // ignore_for_file: type=lint // // ignore_for_file: // ''', // ); }

vasilich6107 commented 3 weeks ago

hey @airychkov probably options: options, where missing one moment I'll release new version

vasilich6107 commented 3 weeks ago

check reactive_forms_generator 5.0.4

airychkov commented 3 weeks ago

Hey! it's working. Thank you

github-actions[bot] commented 3 weeks ago

Hi @airychkov! 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