-
Notifications
You must be signed in to change notification settings - Fork 34
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
Build runner fails due to misplaced import directives in generated files #547
Comments
I'm trying: flutter clean
dart run build_runner clean
dart run build_runner build but tha doesn't solve the issue |
I found a way to regenerate the code: rm lib/brick/db/*migration.dart
rm lib/brick/**/*.g.dart
dart run build_runner clean
dart run build_runner build The problem is that this deletes the migration files, causing the app to crash on startup because it can't execute them. Since I'm still in development, it's not a big issue—I simply uninstall and reinstall the app, and it works. However, once I'm in production, I won’t be able to do that! |
I can confirm the issue. @injectable
class TripFormCubit extends Cubit<TripFormState> {
final GetVehicleUseCase _getVehicleUseCase;
final GetDriversUseCase _getDriversUseCase; // this dep
// ... When I ran the command error message
|
hum, may be a start:
|
@guiyomh thank you for formatting the code in this issue properly. As far as I can tell, the error is being reported by Brick but there is no Brick code. Build Runner can be finicky because it uses
I'm still working on upgrading Brick to the latest packages in #544 . Hopefully I'll have this done by the end of next week. |
(But I'd also accept PRs into #544 to resolve test cases if you'd like to expedite that work) |
When running
dart run build_runner build
in a project usingbrick_offline_first_with_supabase_build
, the process fails due to incorrectly placed import directives in the generated filemodels_and_migrations.brick_aggregate.dart.
Error message:
This suggests that import, export, or part directives are being placed after declarations, causing the build process to break.
I did not modify the model; I was working on a different feature of my app. I created a Cubit using BLoC, where I injected use cases via GetIt. That's why I ran the command to rebuild my dependency injection container.
The code where I work
I wonder if the syntax
part 'trip_form_state.dart';
is well managed ?full log details
```bash dart run build_runner build Building package executable... Built build_runner:build_runner. [INFO] Generating build script completed, took 192ms [WARNING] Throwing away cached asset graph because the build phases have changed. This most commonly would happen as a result of adding a new dependency or updating your dependencies. [WARNING] Throwing away cached asset graph because the language version of some package(s) changed. This would most commonly happen when updating dependencies or changing your min sdk constraint. [INFO] Cleaning up outputs from previous builds. completed, took 66ms [INFO] Generating build script completed, took 81ms [WARNING] Invalidated precompiled build script due to missing asset graph. [INFO] Precompiling build script... completed, took 610ms [INFO] Building new asset graph completed, took 884ms [INFO] Found 1 declared outputs which already exist on disk. This is likely because the`.dart_tool/build` folder was deleted, or you are submitting generated files to your source repository. Delete these files? 1 - Delete 2 - Cancel build 3 - List conflicts 1 [INFO] Checking for unexpected pre-existing outputs. completed, took 2.5s [SEVERE] brick_offline_first_with_supabase_build:brick_schema_builder on lib/models_and_migrations.brick_aggregate.dart:This builder requires Dart inputs without syntax errors.
However, package:apc_portal/models_and_migrations.brick_aggregate.dart (or an existing part) contains the following errors.
models_and_migrations.brick_aggregate.dart:124:1: Directives must appear before any declarations.
Try fixing the errors and re-running the build.
[SEVERE] brick_offline_first_with_supabase_build:brick_new_migration_builder on lib/models_and_migrations.brick_aggregate.dart:
This builder requires Dart inputs without syntax errors.
However, package:apc_portal/models_and_migrations.brick_aggregate.dart (or an existing part) contains the following errors.
models_and_migrations.brick_aggregate.dart:124:1: Directives must appear before any declarations.
Try fixing the errors and re-running the build.
[SEVERE] brick_offline_first_with_supabase_build:brick_model_dictionary_builder on lib/models_and_migrations.brick_aggregate.dart:
This builder requires Dart inputs without syntax errors.
However, package:apc_portal/models_and_migrations.brick_aggregate.dart (or an existing part) contains the following errors.
models_and_migrations.brick_aggregate.dart:124:1: Directives must appear before any declarations.
Try fixing the errors and re-running the build.
[INFO] Running build completed, took 11.0s
[INFO] Caching finalized dependency graph completed, took 47ms
[SEVERE] Failed after 11.1s
The text was updated successfully, but these errors were encountered: