flutterriverpodbuild-runnerriverpod-generator

Moving my riverpods generated files to a dedicated folder


I'm doing some cleaning in my project, therefore I want to move my generated files to an other folder to improve the readability. I've managed to move freezed files but not riverpod This is my build.yaml

targets:
  $default:
    builders:
      source_gen|combining_builder:
        generate_for:
          - lib/**.dart
        options:
          build_extensions:
            '^lib/src/data/dtos/{{file}}.dart': 'lib/src/data/dtos/generated/{{file}}.g.dart'
      freezed|freezed:
        enabled: true
        options:
          build_extensions:
            '^lib/src/data/dtos/{{file}}.dart': 'lib/src/data/dtos/generated/{{file}}.freezed.dart'
      riverpod_generator:
        enabled: true
        options:
          build_extensions:
            '^lib/src/domain/states/{{file}}.dart': 'lib/src/domain/states/generated/{{file}}.g.dart'

part 'generated/my_notifier.g.dart'; in my notifiers

How can I move my riverpods file in a generated folder ? I refered to https://github.com/rrousselGit/riverpod/blame/master/packages/riverpod_generator/build.yaml but didn't manage to make it work


Solution

  • I forgot to put a riverpods entry on source_gen|combining_builder -> build_extensions set. It's working fine now

    build.yaml

    targets:
      $default:
        builders:
          source_gen|combining_builder:
            generate_for:
              - lib/**.dart
            options:
              build_extensions:
                {
                  "lib/src/data/dtos/{{file}}.dart": "lib/src/data/dtos/generated/{{file}}.g.dart",
                  "lib/src/domain/states/{{file}}.dart": "lib/src/domain/states/generated/{{file}}.g.dart",
                }
          freezed|freezed:
            options:
              build_extensions:
                "^lib/src/data/dtos/{{file}}.dart": "lib/src/data/dtos/generated/{{file}}.freezed.dart"
          riverpod_generator:
            options:
              provider_name_prefix: ""
              provider_family_name_prefix: ""
              provider_name_suffix: "Provider"
              provider_family_name_suffix: "Provider"