refactor: remove KyeType and use String for queryKey and mutationKey
This commit is contained in:
@@ -21,8 +21,7 @@ class _InfiniteQueryPageWidgetState extends State<InfiniteQueryPageWidget> {
|
||||
super.initState();
|
||||
controller.addListener(() async {
|
||||
if (controller.position.pixels == controller.position.maxScrollExtent) {
|
||||
final query = QueryClient.of(context)
|
||||
.getInfiniteQuery(const ValueKey("products"));
|
||||
final query = QueryClient.of(context).getInfiniteQuery("products");
|
||||
await query?.fetchNext();
|
||||
}
|
||||
});
|
||||
@@ -40,8 +39,8 @@ class _InfiniteQueryPageWidgetState extends State<InfiniteQueryPageWidget> {
|
||||
appBar: AppBar(
|
||||
title: const Text('Infinite Query'),
|
||||
),
|
||||
floatingActionButton: InfiniteQueryListenable(const ValueKey("products"),
|
||||
builder: (context, query) {
|
||||
floatingActionButton:
|
||||
InfiniteQueryListenable("products", builder: (context, query) {
|
||||
return FloatingActionButton(
|
||||
onPressed: () {
|
||||
query?.fetchNext();
|
||||
@@ -49,8 +48,8 @@ class _InfiniteQueryPageWidgetState extends State<InfiniteQueryPageWidget> {
|
||||
child: Text(query?.pages.length.toString() ?? "-69"),
|
||||
);
|
||||
}),
|
||||
body: InfiniteQueryBuilder<PagedProducts, ClientException, String, int>(
|
||||
const ValueKey("products"),
|
||||
body: InfiniteQueryBuilder<PagedProducts, ClientException, int>(
|
||||
"products",
|
||||
(page) async {
|
||||
final res = await get(Uri.parse(
|
||||
"https://dummyjson.com/products?limit=10&skip=${page * 10}",
|
||||
|
||||
@@ -35,9 +35,9 @@ class _MutationPageState extends State<MutationPage> {
|
||||
appBar: AppBar(
|
||||
title: const Text('Mutation'),
|
||||
),
|
||||
body: MutationBuilder<Map<String, dynamic>, dynamic, String,
|
||||
Map<String, dynamic>, dynamic>(
|
||||
const ValueKey('sign-up'),
|
||||
body: MutationBuilder<Map<String, dynamic>, dynamic, Map<String, dynamic>,
|
||||
dynamic>(
|
||||
'sign-up',
|
||||
(variables) {
|
||||
return Future.delayed(
|
||||
const Duration(seconds: 1),
|
||||
@@ -56,9 +56,7 @@ class _MutationPageState extends State<MutationPage> {
|
||||
print('onData: $data');
|
||||
print('recoveryData: $recoveryData');
|
||||
},
|
||||
refreshQueries: const [
|
||||
ValueKey('hello'),
|
||||
],
|
||||
refreshQueries: const ['hello'],
|
||||
builder: (context, mutation) {
|
||||
if (mutation.hasData) {
|
||||
return ListView(
|
||||
|
||||
@@ -13,8 +13,8 @@ class QueryPage extends StatelessWidget {
|
||||
appBar: AppBar(
|
||||
title: const Text('Query'),
|
||||
),
|
||||
floatingActionButton: QueryListenable<String, dynamic, String>(
|
||||
const ValueKey('hello'), builder: (context, query) {
|
||||
floatingActionButton:
|
||||
QueryListenable<String, dynamic>('hello', builder: (context, query) {
|
||||
if (query == null) {
|
||||
return const SizedBox();
|
||||
}
|
||||
@@ -25,8 +25,8 @@ class QueryPage extends StatelessWidget {
|
||||
child: Text(query.data ?? 'No Data'),
|
||||
);
|
||||
}),
|
||||
body: QueryBuilder<String, dynamic, String>(
|
||||
const ValueKey('hello'),
|
||||
body: QueryBuilder<String, dynamic>(
|
||||
'hello',
|
||||
() {
|
||||
return Future.delayed(
|
||||
const Duration(seconds: 6), () => 'Hello World! $value');
|
||||
|
||||
Reference in New Issue
Block a user