-1
InkWell(
                onTap: () {
                  Get.put<DetailsPaymentHistoryController>(
                      DetailsPaymentHistoryController(
                          paymentHistoryApi: PaymentHistoryApi(),
                          invoiceId: payment.invoiceId!.toString()));
                  Get.toNamed(Routes.detailsHistoryPayment);
                },
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.end,
                  children: [
                    Text(
                      'More Details',
                      style: getSemiBoldStyle(
                          color: Colormanager.primary,
                          fontSize: FontSize.s15),
                    ),
                    const SizedBox(
                      width: AppSize.s4,
                    ),
                    Icon(
                      Icons.read_more,
                      color: Colormanager.darkPrimary,
                    )
                  ],
                ),
              ),

Suppose there some card and those card has their own ivoiceId "yxz123" when i press "More Details" button it route me to the "detailsHistoryPayment" page acording to invoiceId where has some property.but whene i go back and press another "More Details" button it route me the same previous InvoiceId page. it is not showing the new invoiceId's page.

class DetailsPaymentHistoryController extends GetxController
    with StateMixin<DetailsHistoryPaymentResponse> {
  PaymentHistoryApi paymentHistoryApi;
  String invoiceId;
  DetailsPaymentHistoryController({
   required this.paymentHistoryApi,
   required this.invoiceId,
  });

  @override
  void onInit() {
   if (kDebugMode) {
  print('--------------------------');
  print(invoiceId);
}
getPaymentHistoryDetails();
super.onInit();

}

//Get Dashboard Data getPaymentHistoryDetails() async { change(null, status: RxStatus.loading());

try {
  paymentHistoryApi
      .getPaymentHistoryDetails(invoiceId: invoiceId)
      .then((value) {
    var body = json.decode(value);
    print(invoiceId);

    change(DetailsHistoryPaymentResponse.fromJson(body),
        status: RxStatus.success());
    if (kDebugMode) {
      print(value);
    }
  }).onError((error, stackTrace) {
    change(null, status: RxStatus.error(AppStrings.somthingWentWrong));
    if (kDebugMode) {
      print(value);
    }
  });
} catch (error) {
  change(null, status: RxStatus.error(error.toString()));
  if (kDebugMode) {
    print(value);
  }
}
  }
}
 ............................
 Future<dynamic> getPaymentHistoryDetails({
    required String? invoiceId,
    }) =>
    http
      .get(
        Uri.parse(
            '${BaseUrl.baseUrl}/payment-history-details-merchant?invoice_id=$invoiceId'),
        headers: <String, String>{
          'Accept': 'application/json; charset=UTF-8',
          'Authorization': 'Bearer ${StorageHelper.getString(key: 'token')}'
        },
      )
      .then((value) => value.body)
      .onError((error, stackTrace) => Future.error(error.toString()));
}

I tried Get.toNamed(Routes.detailsHistoryPayment); to Get.offNamed(Routes.detailsHistoryPayment); and it work but it route me to two previous page. But i want to go back just previous page. Is there any way to go back to previous page and previous page got reload automaticly???

2 Answers2

0

To go previous page, execute below.

Get.back();

And you could refresh previous page after await Get.toNamed('...');

onTap: () async {
  ...
  await Get.toNamed(Routes.detailsHistoryPayment);
  // TODO: yourController.yourRefreshMethod();              
},
debug_ing
  • 476
  • 3
  • 13
  • it's not helping.. work same as before... i pressed More details and for 1st time it works fine... it route acording to invoiceId and then i go back and pressed another more details and it show me the previos invoiceId's property.. not the new one – Mehedi Hasan Sumon Feb 12 '23 at 09:56
0

The main problem happens with my Get.put method. Just writing Get.putAsync method and all goes well.

onTap: () {
                  Get.putAsync<DetailsPaymentHistoryController>(
                      await DetailsPaymentHistoryController(
                          paymentHistoryApi: PaymentHistoryApi(),
                          invoiceId: payment.invoiceId!.toString()));
                  Get.toNamed(Routes.detailsHistoryPayment);
                },