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

getx update not trigger ui refresh in time #3077

Open
86chenjie opened this issue Apr 16, 2024 · 1 comment
Open

getx update not trigger ui refresh in time #3077

86chenjie opened this issue Apr 16, 2024 · 1 comment
Assignees

Comments

@86chenjie
Copy link

As code below, ui will refresh after about 5 seconds. But it should refresh immediately. When comment out those heavy work linnes, refresh is normal.

class MyHomePageController extends GetxController {
  int count = 0;
  
  increment() {
    count += 1;
    update();
    // some heavy work
    for (int i=0;i<5;i++) {
      final pair = generateRSAkeyPair(exampleSecureRandom());
      final public = pair.publicKey;
      final private = pair.privateKey;
    }
  }
}

example demo: https://github.com/86chenjie/getx_update_issue

@allasca
Copy link

allasca commented May 25, 2024

should not be a problem

 onSelectedPetak(String petak) async {
    columns = [];
    rows = [];
    update(); // << update getbuilder, remove listview to 0
    List<PetakModel> data = await storageController.getDataPetak(
        selectedDatabase, petak, selectedRph);
    Map json = data[0].toJson();
    for (var e in json.entries) {
      if (disableColumns.contains(e.key)) continue;
      columns.add(DataColumn(label: Text(e.key)));
    }
    for (int i = 0; i < data.length; i++) {
      var d = data[i];
      Map j = d.toJson();
      var cell = <DataCell>[];
      for (var e in j.entries) {
        if (disableColumns.contains(e.key)) continue;
        cell.add(DataCell(Text(e.value)));
      }
      rows.add(
        DataRow(
          selected: i.isEven,
          cells: cell,
        ),
      );
    }
    update(); // << update getbuilder listview is now have a length
  }

this code work good

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants