You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
### Describe the bug
When navigating from Page A to Page B, Page B's view contains an asynchronous callback that calls methods on the controller.
Upon leaving Page B and returning to Page A, the controller's `onDelete` method is triggered, and the controller is disposed as expected.
However, due to the asynchronous callback in Page B still referencing the controller, it gets re-initialized.
When navigating back to Page B again, the controller already exists, and `onInit` or `onReady` are not called, leading to unexpected behavior and missing initialization.
### Reproduction code```dartimport 'package:flutter/material.dart';import 'package:flutter_async_view_test/home/home_controller.dart';import 'package:get/get.dart';class HomeView extends GetView<HomeController> { const HomeView({super.key}); @override Widget build(BuildContext context) { return Scaffold( body: Center( child: ElevatedButton( child: const Text('Next Route'), onPressed: () { Get.toNamed('/second', arguments: {"data": "hello"}); }, ), ), ); }}import 'package:flutter/material.dart';import 'package:flutter_async_view_test/second/second_controller.dart';import 'package:get/get.dart';class SecondView extends GetView<SecondController> { const SecondView({super.key}); @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: const Text("Second"), ), body: Center( child: Column( children: [ Obx(() => Text("Get.arguments is: ${controller.data.value}")), ElevatedButton( onPressed: () async { Future.delayed( const Duration(seconds: 3), () { debugPrint("There's a problem here..."); controller.doSomething(); }, ); }, child: const Text("Click me and go back"), ) ], ), ), ); }}import 'package:flutter/material.dart';import 'package:get/get.dart';class SecondController extends GetxController { final data = "".obs; @override void onInit() { super.onInit(); debugPrint("SecondController on init->${Get.arguments}"); if (Get.arguments != null) { data.value = Get.arguments['data'] ?? ''; } } void doSomething() { debugPrint("call do something"); }}[lib.zip](https://github.com/user-attachments/files/18491859/lib.zip)
To Reproduce
Steps to reproduce the behavior:
Run the app and start on Page A.
Navigate to Page B.
Leave Page B and return to Page A.
Observe that the controller's onClose is triggered.
Wait for the asynchronous task to complete, which re-initializes the controller.
Navigate back to Page B.
Observe that the controller's onInit and onReady methods are not called.
Expected behavior
When returning to Page B after the controller has been disposed, the controller should be fully re-initialized, including triggering onInit and onReady.
Flutter Version:
Flutter 3.24.5
Getx Version:
5.0.0-release-candidate-9.2.1
The text was updated successfully, but these errors were encountered:
To Reproduce
Steps to reproduce the behavior:
onClose
is triggered.onInit
andonReady
methods are not called.Expected behavior
When returning to Page B after the controller has been disposed, the controller should be fully re-initialized, including triggering
onInit
andonReady
.Flutter Version:
Flutter 3.24.5
Getx Version:
5.0.0-release-candidate-9.2.1
The text was updated successfully, but these errors were encountered: