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

Broken file path on Windows in mapper file when the generated dir changed #173

Closed
realth000 opened this issue Feb 23, 2024 · 1 comment · Fixed by #174
Closed

Broken file path on Windows in mapper file when the generated dir changed #173

realth000 opened this issue Feb 23, 2024 · 1 comment · Fixed by #174

Comments

@realth000
Copy link
Contributor

realth000 commented Feb 23, 2024

Description

I encountered this error when using v4.2.0 (latest version) on Windows with the following build config:

targets:
  $default:
    builders:
      dart_mappable_builder:
        options:
          build_extensions:
            'lib/{{}}.dart':
              - 'lib/generated/{{}}.mapper.dart'

The config above moved the generated mapper file from some/path/to/foo.mapper.dart to lib/generated/some/path/to/foo.mapper.dart and on Windows platform in the Generated code, the part of statement broke like this:

part of '..\main.dart';

which should be part of ..\\main.dart or part of ../main.dart.

Reproduce

Just use the repo here.

Or:

  1. Create a new flutter project and add dart_mappable (also the builder) as dependency.
  2. Add some code to use dart_mappable in main.dart:
part '../generated/main.mapper.dart';

@MappableClass()
class Foo with FooMappable {}
  1. Save the following config in build.yaml:
targets:
  $default:
    builders:
      dart_mappable_builder:
        options:
          build_extensions:
            'lib/{{}}.dart':
              - 'lib/generated/{{}}.mapper.dart'
  1. Run dart run build_runner build and in the generated file there is:
    part of '..\main.dart'; which is broken on Windows.

Info

  • dart_mappable version: v4.2.0
  • dart_mappable_builder version: v4.2.0
  • flutter version: 3.19.1
  • OS: Windows 10
@realth000
Copy link
Contributor Author

realth000 commented Feb 23, 2024

It seems replace the path separater \ with / can fix this like here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant