2

In my login controller:

class LoginController extends GetxController {
  final GlobalKey<FormState> loginFormKey = GlobalKey<FormState>();

  late TextEditingController emailController, passwordController;
  var isloading = false.obs;    <<<<<<<<<<<<
...

and in my view file:

 Container(
  color: Colors.blueGrey,
  width: double.infinity,
  height: 150,

  child: Obx(()=>
    Center(
      child: logincontroller.isloading ? CircularProgressIndicator(): Container(),

    ),
  )
)

however I keep getting this message:

33:50: Error: A value of type 'RxBool' can't be assigned to a variable of type 'bool'.

a.ak
  • 659
  • 2
  • 12
  • 26
Karan V
  • 163
  • 2
  • 10

1 Answers1

1

Try logincontroller.isLoading.value to check the value of RxBool

esentis
  • 4,190
  • 2
  • 12
  • 28
  • thank you that solved that problem however: now when the isloading variable changes to true (upon the login button click), the circularprogressindicator doesnt show automatically. it only shows after i do a refresh/hot reload. – Karan V Sep 04 '21 at 16:41
  • basically the widget didnt rebuild. when isloading changed value from false to true. child: Obx(()=> Center( child: logincontroller.isloading.value ? new CircularProgressIndicator(): new Container(child: Text('hello its false')), ) – Karan V Sep 04 '21 at 17:09
  • How do you change the value ? – esentis Sep 04 '21 at 18:19
  • using a login button to make a post call to the api. Future checkLogin() async { isloading = true.obs; //right here. – Karan V Sep 04 '21 at 18:40
  • Try changing the value like so `isLoading.value = true` – esentis Sep 04 '21 at 18:49
  • 1
    you the real MVP. it worked! can you explain to me why thats the case. Even tho the value technically was changing before as well? – Karan V Sep 04 '21 at 18:52
  • Awesome, I'm glad I helped. This is how GetX works, try checking the in-depth documentation here https://github.com/jonataslaw/getx/blob/master/documentation/en_US/state_management.md – esentis Sep 04 '21 at 18:54