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

Choose where to create the hive_registrar.g.dart file #36

Open
kaciula opened this issue Oct 23, 2024 · 2 comments · May be fixed by #35
Open

Choose where to create the hive_registrar.g.dart file #36

kaciula opened this issue Oct 23, 2024 · 2 comments · May be fixed by #35
Labels
question Further information is requested

Comments

@kaciula
Copy link

kaciula commented Oct 23, 2024

Is there a way to specify where to create the hive_registrar.g.dart file? Currently, it is being created in the main lib folder. I would much prefer to control where to place it in the file hierarchy (e.g closer to where the database is)

@kaciula kaciula added the question Further information is requested label Oct 23, 2024
@Rexios80
Copy link
Member

There is not currently, but I am working on a new way to generate type adapters in #35. I will make it so that hive_registrar.g.dart is placed in the same directory as the file containing the @GenerateAdapters annotation.

@Rexios80 Rexios80 linked a pull request Oct 23, 2024 that will close this issue
@Rexios80
Copy link
Member

Rexios80 commented Oct 23, 2024

I added the feature to that PR. Could you try this and see if it does what you need?

pubspec.yaml

dependency_overrides:
  hive_ce:
    git:
      url: https://github.com/IO-Design-Team/hive_ce
      ref: 7a0792d407d7563f56a88bcb3d8427e4a9315968
      path: hive
  hive_ce_generator:
    git:
      url: https://github.com/IO-Design-Team/hive_ce
      ref: 7a0792d407d7563f56a88bcb3d8427e4a9315968
      path: hive_generator

Create a file where you want hive_registrar.g.dart to be containing the following:

import 'package:hive_ce/hive.dart';

part '{YOUR_FILE_NAME}.g.dart';

@GenerateAdapters([AdapterSpec<StubType>()])
class StubType {}

You could transition your project to using @GenerateAdapters, but I'm not sure how much work that would be for you (and also the feature is not quite stable yet). If you are interested in attempting the migration for science, see the documentation here.

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

Successfully merging a pull request may close this issue.

2 participants