AngularDart - stagehand web-angular material_ripple.scss error - angular-dart

Following this
And using cli
stagehand web-angular
pub get
webdev serve
Output:
[INFO] Setting up file watchers completed, took 25ms
[INFO] Waiting for all file watchers to be ready completed, took 201ms
[INFO] Building new asset graph completed, took 1.2s
[INFO] Checking for unexpected pre-existing outputs. completed, took 1ms
[SEVERE] angular_components|scss_builder on package:angular_components/material_ripple/material_ripple.scss:
Error: Can't find stylesheet to import.
#import 'const/global',
^^^^^^^^^^^^^^
/private/var/folders/3p/8z23nlbs20qf291vlhjy1l0h0000gn/T/scratch_spaceuuJ2f0/packages/angular_components/css/material/_material.scss 19:9 #import
/private/var/folders/3p/8z23nlbs20qf291vlhjy1l0h0000gn/T/scratch_spaceuuJ2f0/packages/angular_components/material_ripple/material_ripple.scss 5:9 root stylesheet
[SEVERE] angular_components|scss_builder on package:angular_components/material_slider/material_slider.scss:
And the list goes on with a lot more
Do you know how to fix this?

This is a known issue. A work around is to add the following dependency override to your project's pubspec.yaml:
dependency_overrides:
sass: 1.3.2

Related

flutter build_runner takes too long

I am using EasyLocalization, mobx, JsonSerializable etc. To generate *.g.dart files, I am using build_runner watch or the script in scripts/build.sh:
flutter packages pub run build_runner build
It was taking 2 seconds at most, but then suddenly it started to take at least 10 seconds or sometimes 30 seconds. Because of this situation, build_runner watch became useless, I mean it's not working properly since then.
The output on the console when I run my script:
$ sh scripts/build.sh
[INFO] Generating build script...
[INFO] Generating build script completed, took 611ms
[INFO] Initializing inputs
[INFO] Reading cached asset graph...
[INFO] Reading cached asset graph completed, took 126ms
[INFO] Checking for updates since last build...
[INFO] Checking for updates since last build completed, took 745ms
[INFO] Running build...
[INFO] 1.2s elapsed, 0/16 actions completed.
[INFO] 2.2s elapsed, 0/16 actions completed.
[INFO] 3.3s elapsed, 0/16 actions completed.
[INFO] 12.5s elapsed, 1/17 actions completed.
[INFO] 13.6s elapsed, 4/20 actions completed.
[INFO] Running build completed, took 14.6s
[INFO] Caching finalized dependency graph...
[INFO] Caching finalized dependency graph completed, took 57ms
[INFO] Succeeded after 14.6s with 2 outputs (47 actions)
I finally decided to try and solve this myself, I've improved it slightly by adding the following to my pubspec.yaml: E.g.
targets:
$default:
builders:
json_serializable:
enabled: true
generate_for:
include:
- lib/your_codegen_folder/**.dart
- lib/**.gen.dart
Hope this speeds it up a little for you. You'll have to add builder configs for your other two generators like the json_serializable one here. I suspect they might be referred to easy_localization and mobx? I don't know, I'm new to this.
In addition to avoiding running builders on unnecessary inputs I manage to make my builds MUCH faster by disabling the mockito mock generator, which I was not using:
targets:
$default:
builders:
your_builder:
generate_for:
- lib/**/*.dart
mockito:mockBuilder:
enabled: false
Running a build was causing Mockito to search every one of my test files for #GenerateMocks.

ObjectBox does not build after Dart SDK update

I was using ObjectBox without many problems for a while during a development with Flutter, but now the build_runner fails:
The closest change I have made is a Flutter upgrade yesterday to Flutter 2.5.3 along with Dart 2.14.4.
ObjectBox dependencies in pubspec.yaml are:
objectbox: ^1.2.0
objectbox_flutter_libs: any
Now, although the objectbox-model.json file is there, the objectbox.g.dart file is missing and does not get regenerated.
I then tried to run the two example projects give in the official OB documents, but those failed too with similar results (they ran OK before this).
The complete build stack is as follows:'
Microsoft Windows [Version 10.0.19042.1237] (c) Microsoft Corporation. All rights reserved.
D:\learnedfriend>flutter pub run build_runner watch --delete-conflicting-outputs
[INFO] Generating build script...
[INFO] Generating build script completed, took 462ms
[INFO] Setting up file watchers...
[INFO] Setting up file watchers completed, took 11ms
[INFO] Waiting for all file watchers to be ready...
[INFO] Waiting for all file watchers to be ready completed, took 358ms
[INFO] Initializing inputs
[INFO] Reading cached asset graph...
[INFO] Reading cached asset graph completed, took 126ms
[INFO] Checking for updates since last build...
[INFO] Checking for updates since last build completed, took 6.3s
[INFO] Running build...
[INFO] Running build completed, took 14ms
[INFO] Caching finalized dependency graph...
[INFO] Caching finalized dependency graph completed, took 54ms
[SEVERE] objectbox_generator:generator on lib/$lib$ (cached):
Bad state: lastRelationId 4:6834778133563033891 does not match any standalone relation
[SEVERE] Failed after 85ms
I have found a solution to this problem and am posting it for the benefit of whoever encounters the same issue in future.
You should manually delete the objectbox-model.json file and objectbox.g.dart (if it still exists) and run the command "flutter pub run build_runner watch --delete-conflicting-outputs" at the project folder (without quotes, of course).
Also, it has to be mentioned that, as at the time of writing this post, if ObjectBox is a contemplated choice for your persistence, please be wary that (although it is an excellent package), support for a problem if you get stuck is very low to nil, in stackoverflow. I have not seen more than 2 or 3 contributors and if your question escapes their attention, you are pretty much on your own!

Issues with build_runner after adding Hive Field

I have added addtional Hive Fields to a Hive type before as needed. I have then deleted .g.dart file and regenerated it with no problems.
This time after added a new Hive Field I have this error and I am not able to understand why
[INFO] Generating build script...
[INFO] Generating build script completed, took 424ms
[INFO] Initializing inputs
[INFO] Reading cached asset graph...
[INFO] Reading cached asset graph completed, took 73ms
[INFO] Checking for updates since last build...
[INFO] Checking for updates since last build completed, took 968ms
[INFO] Running build...
[INFO] Running build completed, took 21ms
[INFO] Caching finalized dependency graph...
[INFO] Caching finalized dependency graph completed, took 55ms
[SEVERE] hive_generator:hive_generator on lib/main.dart (cached):
This builder requires Dart inputs without syntax errors.
However, package:flutter_app_hive/main.dart (or an existing part) contains the following errors.
main.dart:33:3: Expected to find ';'.
main.dart:33:3: Expected an identifier.
Try fixing the errors and re-running the build.
[SEVERE] Failed after 92ms
pub finished with exit code 1
I have tried flutter clean, flutter pub outdated, pub get, etc... and I keep getting this error.
In my pubspec.yaml I have, this worked just fine until I have added the latest Hive Field.
dependencies:
flutter:
sdk: flutter
hive: ^2.0.2
hive_flutter: ^1.0.0
path_provider: ^2.0.1
curved_navigation_bar: ^0.3.7
video_player: ^1.0.1
font_awesome_flutter: ^8.5.0
badges: ^1.2.0
cupertino_icons: ^1.0.2
dev_dependencies:
flutter_test:
sdk: flutter
build_runner: ^2.0.1
hive_generator: ^1.1.0
I found an old post about downgrading analyzer, but this then causes problems with the versions I am using.
In the main.dart there isn't an error on line 33:3. it should not have ; as suggested. Again this worked fine before, so I am not sure why it is an issue now. I also commented out the code here and I still get the same error message even with nothing at line 33:3
If I remove the field I added I still get the same error. If I restore the .g.dart file from a backup I can run the app as before.
Any input on this would be appreciated as it's very confusing
Update:
So I tried deleting the model file and completely recreating it and then generating the .g.dart. I get this:
[INFO] Generating build script...
[INFO] Generating build script completed, took 485ms
[INFO] Initializing inputs
[INFO] Reading cached asset graph...
[INFO] Reading cached asset graph completed, took 83ms
[INFO] Checking for updates since last build...
[INFO] Checking for updates since last build completed, took 1.1s
[INFO] Running build...
[INFO] Running build completed, took 23ms
[INFO] Caching finalized dependency graph...
[INFO] Caching finalized dependency graph completed, took 66ms
[INFO] Succeeded after 102ms with 0 outputs (0 actions)
I have tried keeping the file as it was, added a new Hive Field to a previous Hive Type and adding a Hive type and I get nothing generated.
I haven't changed the existing Hive fields, I know that causes issues. New Hive Fields and Hive Types were given the next number that hadn't been used before.
So I didn't fix the issue, but for a work around I created a new flutter project, copied my code over except any generated files. Then I was able to generate new type adapters after adding new Hive fields and hive types. Maybe something got corrupted in my previous project. Not sure why flutter clean wouldn't fix this. But maybe this will help someone stuck on the same issue.
Set source_gen: 1.0.3 in pubspec.yaml helped in my case.

analyzer require 'non-nullable' language feature to be enabled

I did a mistake by migrating to null-safety then every thing become error, after fixing a lot of errors, I still get an error and the error is :
[INFO] Generating build script...
[INFO] Generating build script completed, took 452ms
[INFO] Initializing inputs
[INFO] Reading cached asset graph...
[INFO] Reading cached asset graph completed, took 131ms
[INFO] Checking for updates since last build...
[INFO] Checking for updates since last build completed, took 791ms
[INFO] Running build...
[INFO] Running build completed, took 30ms
[INFO] Caching finalized dependency graph...
[INFO] Caching finalized dependency graph completed, took 79ms
[SEVERE] json_serializable:json_serializable on lib/injection.config.dart (cached):
This builder requires Dart inputs without syntax errors.
However, package:invoice_app/injection.config.dart (or an existing part) contains the following errors.
injection.config.dart:18:48: This requires the 'non-nullable' language feature to be enabled.
injection.config.dart:18:12: This requires the 'non-nullable' language feature to be enabled.
Try fixing the errors and re-running the build.
[SEVERE] Failed after 123ms
pub finished with exit code 1
it's look like injectable generator have some mix up with the new version of dart that is why when I generate new injection.config.dart file then it gave this error
injection.config.dart:18:12: This requires the 'non-nullable' language feature to be enabled.
so if you want to fix it just open the file then then remove the ? mark like from this
_i1.GetIt $initGetIt(_i1.GetIt get,
{String? environment, _i2.EnvironmentFilter? environmentFilter}) {
final gh = _i2.GetItHelper(get, environment, environmentFilter);
return get;
}
to this
_i1.GetIt $initGetIt(_i1.GetIt get,
{String environment, _i2.EnvironmentFilter environmentFilter}) {
final gh = _i2.GetItHelper(get, environment, environmentFilter);
return get;
}
I know it's not a solution but it works until when I will migrate to non-nullable, I will use this.

flutter: Can't create moor_database.g.dart file

I am trying to learn moor_flutter so i added some dependencies into pupspec.yaml:
dependencies:
flutter:
sdk: flutter
moor_flutter: ^2.1.1
provider: ^4.0.4
flutter_slidable: ^0.5.4
path_provider: ^1.6.5
path: ^1.6.4
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.2
dev_dependencies:
moor_generator: ^2.4.0
build_runner: ^1.8.1
flutter_test:
sdk: flutter
After installing these dependencies I create a table class inside lib -> data -> moor_database.dart file:
import 'package:moor_flutter/moor_flutter.dart';
part 'moor_database.g.dart';
class Tasks extends Table {
IntColumn get id =>
integer().autoIncrement().call();
TextColumn get name => text().withLength(min: 1, max: 50)();
DateTimeColumn get dueDate => dateTime().nullable()();
BoolColumn get completed => boolean().withDefault(Constant(false))();
}
#UseMoor(tables: [Tasks])
class AppDatabase extends _$AppDatabase {
AppDatabase()
: super(FlutterQueryExecutor.inDatabaseFolder(
path: 'db.sqlite', logStatements: true));
#override
int get schemaVersion => 1;
}
I want to generate dart code by :
flutter packages pub run build_runner watch
But i got this error:
$ flutter packages pub run build_runner watch
[INFO] Generating build script...
[INFO] Generating build script completed, took 349ms
[INFO] Setting up file watchers...
[INFO] Setting up file watchers completed, took 12ms
[INFO] Waiting for all file watchers to be ready...
[INFO] Waiting for all file watchers to be ready completed, took 165ms
[INFO] Initializing inputs
[INFO] Reading cached asset graph...
[INFO] Reading cached asset graph completed, took 68ms
[INFO] Checking for updates since last build...
[INFO] Checking for updates since last build completed, took 889ms
[INFO] Running build...
[INFO] 1.6s elapsed, 0/1 actions completed.
[INFO] 3.4s elapsed, 0/1 actions completed.
[SEVERE] moor_generator:moor_generator on lib/data/moor_database.dart:
Error running MoorGenerator
NoSuchMethodError: The getter 'typeConverter' was called on null.
Receiver: null
Tried calling: typeConverter
[SEVERE] moor_generator:moor_generator on lib/data/moor_database.dart:
Error running DaoGenerator
NoSuchMethodError: The getter 'typeConverter' was called on null.
Receiver: null
Tried calling: typeConverter
[INFO] Running build completed, took 3.7s
[INFO] Caching finalized dependency graph...
[INFO] Caching finalized dependency graph completed, took 50ms
[SEVERE] Failed after 3.7s
After googleing i found this solution :
but after running flutter packages pub run build_runner build --delete-conflicting-outputs i got this error:
flutter packages pub run build_runner build --delete-conflicting-outputs
[INFO] Generating build script...
[INFO] Generating build script completed, took 350ms
[INFO] Initializing inputs
[INFO] Reading cached asset graph...
[INFO] Reading cached asset graph completed, took 79ms
[INFO] Checking for updates since last build...
[INFO] Checking for updates since last build completed, took 896ms
[INFO] Running build...
[INFO] Running build completed, took 11ms
[INFO] Caching finalized dependency graph...
[INFO] Caching finalized dependency graph completed, took 47ms
[SEVERE] moor_generator:moor_generator on lib/data/moor_database.dart (cached):
Error running MoorGenerator
NoSuchMethodError: The getter 'typeConverter' was called on null.
Receiver: null
Tried calling: typeConverter
[SEVERE] moor_generator:moor_generator on lib/data/moor_database.dart (cached):
Error running DaoGenerator
NoSuchMethodError: The getter 'typeConverter' was called on null.
Receiver: null
Tried calling: typeConverter
[SEVERE] Failed after 71ms
pub finished with exit code 1
I asked a question in it's official repo git and i got this answer :
It works if you replace this with integer().autoIncrement()(). The generator should emit a more helpful error message though, I'll take a look at why that didn't happen here.
I chnaged:
IntColumn get id =>integer().autoIncrement().call();
to :
IntColumn get id =>integer().autoIncrement()();
my problem gone.