0

Why can I not access the id of my object within a worker of GetX?

enter image description here

Here is my controller:

class SelectedSecretController extends GetxController {

  Rx<Secret> selectedSecret = Secret().obs;


  void setSelectedSecret(secret) {
    selectedSecret.value = secret;
 }
}

Here is my secret model:

class Secret {
  String id;
  String full_name;

  Secret({this.id = "", this.full_name = ""});
}
Martin Seubert
  • 978
  • 3
  • 21
  • 37

1 Answers1

2

For some reason you need to explicitly specify the type of the callback parameter as of now (may be limitation of the dart generics).

So instead of this:

 ever(selectedSecret, (val) {
  print(val.id);
 });

You need to do like this:

 ever(selectedSecret, (Secret val) {
  print(val.id);
 });
S. M. JAHANGIR
  • 4,324
  • 1
  • 10
  • 30