Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 12111

using flutter Getx binding that is visible in visibility does not work even if the data has changed

$
0
0

i make a onboarding page using flutter and getx state management with binding,
when i try to set the visible the ui is not updating, so when im at the last page the skip and next icon is not gone and the button get started is not appears,also when im using Obx its say

      [Get] the improper use of a GetX has been detected.       You should only use GetX or Obx for the specific widget that will be updated.      If you are seeing this error, you probably did not insert any observable variables into GetX/Obx       or insert them outside the scope that GetX considers suitable for an update       (example: GetX => HeavyWidget => variableObservable).      If you need to update a parent widget and a child widget, wrap each one in an Obx/GetX.

i tried to set the visible with a bool from onboarc controller like this

//button get startedVisibility(  visible: controller.isLastPage == true,

and this

//skip and next buttonVisibility(  visible: controller.isLastPage == false,

and here is how i change in pageview.builder

onPageChanged: (index) {  controller.isLastPage = index == 1;},

while like here how i use in controller

bool isLastPage = false;void nextPage() {    currentPage.value++;// i want to see the value of it    print(isLastPage);    if (currentPage.value >= 3) {      // Jika sudah sampai halaman terakhir, pindah ke halaman selanjutnya      Get.offAllNamed('/home');    } else {      pageController.nextPage(duration: Duration(milliseconds: 300), curve: Curves.ease);      isLastPage = true;    }  }

for refrence here is how i code for the onboarding

Expanded(  child: PageView.builder(    controller: controller.pageController,    itemCount: pageContent.length,    itemBuilder: (context, index) {      print(index);      return Column(        mainAxisAlignment: MainAxisAlignment.center,        children: [          Image.asset(            pageContent[index]['image'],            fit: BoxFit.fill,            width: 450,            height: 600,          ),          SizedBox(height: 20),          Text(            pageContent[index]['header'],            style: onboardingHeaderTextStyle,            textAlign: TextAlign.center,          ),          SizedBox(height: 10),          Text(            pageContent[index]['subheader'],            maxLines: 3,            style: onboardingSubHeaderTextStyle,            textAlign: TextAlign.center,          ),          SizedBox(height: 5),        ],      );    },    onPageChanged: (index) {      controller.isLastPage = index == 1;    },  ),),

Viewing all articles
Browse latest Browse all 12111

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>