I am porting my API from Swift to a Flutter app, and the calls are using generics to cut down on rewriting calls to various endpoints.
Using the riverbed_repo_generator example I made an example of what I am trying to achieve.
// File data_repo.dart
import 'package:riverpod_annotation/riverpod_annotation.dart';
import 'package:riverpod_repo/annotations.dart';
part 'data_repo.g.dart';
part 'data_repo.repo.dart';
@Riverpod(keepAlive: true)
RepoData repoData(RepoDataRef ref) => RepoDataImpl();
@riverpodRepo
abstract class RepoData {
Future<R?> get<T extends BaseRequest, R extends BaseResponse>(
T request);
}
class RepoDataImpl implements RepoData {
@override
Future<R?> get<T extends BaseRequest, R extends BaseResponse>({required T request}) {
// The implementation logic should be written in this section
}
}
The problem is that in the generated code the provider for the get method cannot understand what R is.
error: The name 'R' isn't a type, so it can't be used as a type argument.
I am porting my API from Swift to a Flutter app, and the calls are using generics to cut down on rewriting calls to various endpoints.
Using the riverbed_repo_generator example I made an example of what I am trying to achieve.
The problem is that in the generated code the provider for the get method cannot understand what R is.
error: The name 'R' isn't a type, so it can't be used as a type argument.
in the generated code
Is it possible to use generic methods? or is it a limitation on the generator that can't correctly construct the provider?