Riverpod generators with abstract classes. #2752
gajendrapandeya
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am using Retrofit + Dio + RiverpodGenerators. So in order to make any request using Retrofit, I have to make a class abstract. So I am doing this
part 'auth_service.g.dart';
///auth service provider
@riverpod
AuthService authService(AuthServiceRef ref) => _AuthService(dio: ref.read(dioProvider));
/// Auth Service class
@RESTapi()
abstract class AuthService {
/// Auth Service constructor
AuthService({required this.dio});
/// Dio instance
final Dio dio;
/// login method to login user
@post(ApiConstants.loginUrl)
Future<Response> login({
@field('email') required String email,
@field('password') required String password,
});
}
Error: I am getting error Abstract class can't be instantiated. Is there any workaround for this?
Beta Was this translation helpful? Give feedback.
All reactions