'How to update my list in flutter when inserting a record?
When I save a record it doesn't update my list. Can anyone see something wrong in the code?
Expanded(
child: Obx( () =>
LazyLoadScrollView(
onEndOfPage: () => controller.netxPage(),
isLoading: controller.lastPageAlgum,
child: ListView.builder(
physics: const BouncingScrollPhysics(),
itemCount: controller.posts.length,
itemBuilder: (context, index) {
return PostWidget(post: controller.posts[index]);
},
),
),
),
),
Solution 1:[1]
I am not sure if this is related to why your code is not updating, but you have a typo for the line
onEndOfPage: () => controller.netxPage(),
It should be
onEndOfPage: () => controller.nextPage(),
Let me know if that helped out
Solution 2:[2]
setState(() {
items.addAll(List.generate(10, (index) => 'Inserted $index'));
});
call setState(() { }
where you add record to your List
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | haroon |
Solution 2 | Anandh Krishnan |