Reputation: 65
Ex: I have one controller on product screen and then I need to click on there product it will show product detail, it's correct scenario alter I have option for click view company profile and then on this company profile have some related product on the company, and then I need click view product related for view product detail, but it still show old data I was click first on product, it should be show lated data. not first data. Anyone face an issue. -> first
Get.toNamed(Routes.productDetail, arguments: {"supplierId": companyId, "product": product});
-> tow click from company profile view product detail
Get.toNamed(Routes.productDetail, arguments: {"supplierId": companyId, "product": product});
I think controller not init again.
Upvotes: 0
Views: 1064
Reputation: 1255
try this since both page have same controller i think the other page wont try to call again the on init
/// this is the value/s lets assume it.
final supplierId = "".obs;
final Rx<Product> product = Product().obs;
//// Funtion to go page
gotoProductDetail({String? companyId, Product? product1}){
supplierId(companyId!);
product(product1!);
////// use update if you are using GetBuilder
update();
Get.toNamed(Routes.productDetail);
}
now access this data to the product detail
class ProductDetails extends StatelessWidget{
........
@override
Widget build(BuildContext context) {
return GetBuilder<YourController>(builder :(controller){
return Scafold(
body: Column(
children: [
Text(controller.product.value.name),
]
)
);
});
}
}
Upvotes: 1