flutter auto route generator error : [dynamic] is not a class - flutter

when I am trying to generate the routes for my app using flutter pub run build_runner build
I'm getting an error and the generated class can't be generated
I only see [dynamic] is not a class in the generated class

try to clean and rebuild it ,It worked for me.
flutter packages pub run build_runner clean
then
flutter packages pub run build_runner build

According to the documentation:
Make sure you always Save your files before running the generator, if that doesn't work you can always try to clean and rebuild.
Then:
flutter packages pub run build_runner clean

Related

Flutter need to call clean and pub get everytime before build_runner

I am using the localize_it package for localization which uses the build_runner to create some code.
The problem/inconvenience is that I always have to run
flutter clean
flutter pub get
before calling
flutter pub run build_runner build --delete-conflicting-outputs
Is there any way I can avoid this? Or can I combing these calls so I can simply call something like flutter localize_it that does everything for me?
I would like to advice https://pub.dev/packages/easy_localization instead of localize_it. It is much more convenient and easy to use.

Build failed with an exception

while running the code got this error. I tried to reinstall the flutter ,but did not work
It looks more like a Java error,
Just to have a clear conscience, i would suggest you to run the very classic
flutter clean
and then
flutter pub get
if you're using build_runner in your project, run:
flutter pub run build_runner build --delete-conflicting-outputs
Restart your computer, it worked for some people with the same problem (Linked at the end).
If nothing of this works, reinstall your Java.
Check this for more info:
Cannot create service of type TaskExecuter using ProjectExecutionServices
https://github.com/gradle/gradle/issues/12436#issuecomment-678389275

Flutter generate Freezed files for Cubit with build_runner not working

I am trying to use the Freezed Package together with the Cubits from the Bloc Package. I followed this tutorial and I want to simply create Cubits with Freezed but I can not make it work.
Calling:
flutter pub run build_runner build --delete-conflicting-outputs
does not create anything.
Here is my setup:
courses_cubit.dart:
import 'package:bloc/bloc.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
part 'courses_state.dart';
part 'courses_cubit.freezed.dart';
class CoursesCubit extends Cubit<CoursesState> {
CoursesCubit() : super(CoursesState.initial());
}
courses_state.dart:
part of 'courses_cubit.dart';
#freezed
class CoursesState with _$CoursesState {
const factory CoursesState.initial() = _Initial;
}
According to the Tutorial and also this article running the command above should create the file courses_cubit_freezed.dart. But like I said, nothing happens. The command runs successfully with no changes.
What am I missing here? Let me know if you need any more info!
guess something was messed up with my cacheor sth. Removing all the packages and installing it like this solved the issue:
Bloc
flutter pub add flutter_bloc
Freezed
flutter pub add freezed_annotation
flutter pub add --dev build_runner
flutter pub add --dev freezed
after installing it simply run this to generate the missing file:
flutter pub run build_runner build

Target file "build_runner" not found. - Flutter GraphQL

flutter run build_runner build - return the following result
Target file "build_runner" not found.
This is supposed to generate model classes from schema, but stuck in the above listed issues.
The issue is with the package dependencies. Executing this flutter pub upgrade --major-versions will solve this issue.

pub run build_runner build has error (66)

hey guys i have error after using command : flutter pub run build_runner build
error message :
C:\Users\matin\AndroidStudioProjects\mosito>flutter pub run build_runner build
Could not find a file named "pubspec.yaml" in "C:\Users\matin\Documents\flutter\.pub-cache\hosted\pub.dartlang.org\async-2.8.1".
pub finished with exit code 66
i try flutter pub upgrade and a lot of things from google but problem not fixed
NOTE: im new to flutter i want use this command for making .g.dart file for my models thanks for your attention
I think may be you are not in your project directory. Suppose you have a project name A in myfolder in C drive of your computer. First goto myfolder with terminal. after that try below code to build the project...
flutter packages pub run build_runner build --delete-conflicting-outputs
Turn on Your Terminal and Run
flutter doctor
if it is showing
Could not find "flutter"
Then you need to install flutter Correctly You Can check :
https://docs.flutter.dev/get-started/install/windows