0

I use the get package, I have a bottom navigation that is updated with Obx. There is also a search for elements, at the top level of the pages everything is updated well, but when I do push, the current page is not updated, only when you call hot reload. There are suspicions that the nested page is not updated due to the fact that it goes beyond the BottomNavigation, and there is no Obx widget.

My Page Navigation controller:

Widget build(BuildContext context) {
    SizeConfig().init(context);
    final BottomPageController landingPageController =
        Get.put(BottomPageController(), permanent: false);
    return SafeArea(
      child: Scaffold(
        bottomNavigationBar:
            BottomNavigationMenu(landingPageController: landingPageController),
        body: Obx(
          () => IndexedStack(
            index: landingPageController.tabIndex.value,
            children: [
              ProductPage(),
              MapPage(),
              ClientPage(),
              NotePage(),
            ],
          ),
        ),
      ),
    );
  }

My page where you need to update the ListView, depending on the entered value in the search bar:

class Product extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return GetX<ProductController>(
      init: ProductController(),
      builder: (controller) {
        return FutureBuilder<List<ProductsCombined>>(
          future: controller.filterProduct.value,
          builder: (context, snapshot) {
            if (snapshot.hasData) {
              return Expanded(
                child: Container(
                  child: ListView.builder(
                    physics: BouncingScrollPhysics(),
                    itemCount: snapshot.data.length,
                    itemBuilder: (BuildContext context, int index) =>
                        ProductCards(
                      product: snapshot.data[index],
                    ),
                  ),
                ),
              );
            } else {
              return Center(child: CircularProgressIndicator());
            }
          },
        );
      },
    );
  }
}

There is also a nested page in the Product class, which is accessed in this way:

onTap: () => {
          Get.toNamed(StoresScreen.routeName, arguments: companies)}

The Product class is updated immediately, you do not need to click Hot reload to do this, and the ProductScreen class that the transition is made to can no longer be updated, these 2 classes are completely identical. The search bar works, but it filters out the elements only after Hot reload.

If you need some other parts of my code, such as a controller that handles ListView, please write, I will attach it.

EDIT: I add a link to the video, with the screen that is not updated

che4len
  • 63
  • 1
  • 7

1 Answers1

0

Obx is a little tricky to work with. I always suggest to use GetX instead.

Try this :

Obx(
      () => IndexedStack(
        index: Get.find<BottomPageController>().tabIndex.value,
        children: [
          ...
        ],
      ),
    ),

If it didn't work use GetX<BottomPageController> for this situation too. It works for all conditions

Ali Rasouli
  • 111
  • 2
  • I think I wrote my question incorrectly, in this place I have just the same update works. The lists are updated, but when I go inside the list item, it is not updated, although the code is completely identical. [Here is the link to the video.](https://disk.yandex.ru/i/_LaAGdJMFwgIbw) – che4len Jun 04 '21 at 08:02
  • And I think because of the fact that the `Client` screen is updated because of what is included in the `IndexedStack` area, wrapped in `Obx`. And when I go inside, it is no longer the scope of this `IndexedStack`, but this is just a guess – che4len Jun 04 '21 at 08:06
  • So far, I haven't been able to fix it – che4len Jun 06 '21 at 10:58
  • If you have a list with custom generic type like List you should use update() when your list updated because rxlist can not detect changes inside the model, it just detects the changes of items inside the list – Ali Rasouli Aug 22 '21 at 08:16
  • 1
    I fixed this by adding Navigator for nested pages – che4len Aug 23 '21 at 08:16