Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generics in Notifier generated #3490

Open
Arpit1496 opened this issue Apr 12, 2024 · 2 comments
Open

Generics in Notifier generated #3490

Arpit1496 opened this issue Apr 12, 2024 · 2 comments
Assignees
Labels
bug Something isn't working riverpod_generator
Milestone

Comments

@Arpit1496
Copy link

II am on latest dev branch of riverpod generator and yet I am facing issues for generics.
The code builder leaves "Generics" in 2 functions:

1). _copyWith: The create Function parameter does not consider Generics and generates a compile time error.

ListBlocProvider _copyWith( ListBloc Function() create, )

2). == override: The first condition of == does not consider generics and hence 2 objects are never equal and generate a compile time error.

@OverRide bool operator ==(Object other) { return other is ListBlocProvider && other.runtimeType == runtimeType && other.getData == getData; }

A sample error message is added for better understanding.

THIS IS WHAT "SHOULD" BE GENERATED:
image

BUT THIS IS WHAT IS GENERATED:
image

@Arpit1496 Arpit1496 added bug Something isn't working needs triage labels Apr 12, 2024
@rrousselGit
Copy link
Owner

Please share your provider definition. The generated code isn't useful to me without seeing the code that generated this.

@rrousselGit rrousselGit added question Further information is requested riverpod_generator and removed needs triage labels Apr 12, 2024
@Arpit1496
Copy link
Author

BASE:

image

import 'package:astra_ui/state/list_state.dart';
import 'package:fast_immutable_collections/fast_immutable_collections.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';

part 'test.g.dart';

typedef ListDataGetter<Model, Sort, Cursor> = Future<(IList, Cursor)>
Function({
Map<String, dynamic> filters,
Sort? sort,
Cursor? cursor,
});

@riverpod
class ListBloc<Model, Sort, Cursor> extends _$ListBloc<Model, Sort, Cursor> {
@OverRide
ListState<Model, Sort, Cursor> build({
required String type,
required ListDataGetter<Model, Sort, Cursor> getData,
String? parentId,
}) {
return ListState<Model, Sort, Cursor>(
data: [].lock,
loading: true,
parentId: parentId,
);
}
}

@rrousselGit rrousselGit removed the question Further information is requested label Apr 12, 2024
@rrousselGit rrousselGit added this to the Riverpod 3.0 milestone Apr 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working riverpod_generator
Projects
None yet
Development

No branches or pull requests

2 participants