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 cache
or 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