KRTirtho / fl-query

Asynchronous data fetching & data invalidation libraries for Flutter
https://fl-query.krtirtho.dev/
Apache License 2.0
60 stars 11 forks source link

data is not loaded after coming back #24

Closed HaraHQ closed 8 months ago

HaraHQ commented 1 year ago

hello, just want to know how to config this correctly, hope that is not bug...

  1. got this file job
    
    import 'package:fl_query/fl_query.dart';
    import 'dart:convert';
    import 'package:http/http.dart' as http;

final exampleQueryJob = QueryJob.withVariableKey<Map, void>( keepPreviousData: true, task: (queryKey, externalData) async { final res = await http.get(Uri( scheme: 'https', host: 'jsonplaceholder.typicode.com', path: 'todos/${getVariable(queryKey)}', queryParameters: {})); return jsonDecode(res.body); }, );


2. then after come to specific page, lets call its a news page (news.dart), the data is loaded and show the data which i call from
```dart
QueryBuilder<Map, void>(
              job: exampleQueryJob(id.toString()),
              externalData: null,
              builder: (context, query) {
                if (!query.hasData || query.isLoading) {
                  return const CircularProgressIndicator();
                } else if (query.isSuccess) {
                  return Text(query.data!['title'],
                      style: const TextStyle(
                        fontSize: 18,
                        fontWeight: FontWeight.w700,
                        color: Colors.red,
                      ));
                } else {
                  return const Text('error...');
                }
              },
            ),
  1. then, the issue that i want to ask about is when, i left the page and re clicking the widget that made me accessing the news.dart again, the fetch process just like stuck and even not showing the CircularProgressIndicator at all; the terminal not displaying any error too, this just like query job is not triggered, the api is not consumed, and the response is not provided anymore...

  2. I already try this again, and after the second access the page, sometime it will stuck (mostly) and sometime (very rare) is show the data.

  3. since, i was only learn flutter a month ago, i don't know if my current project probably causing the errors or not... the is the folder structure of mine:

    • libs
    • /components -> all components here
    • /query_job -> my query job only one here
    • {pages}.dart -> my pages here

any my pages just like this:

KRTirtho commented 1 year ago

fl_query has gone through some major changes which can fix this kind of issue. So please try to reproduce it with latest version (v1.0.0 currently)?