-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Misaligned routes and dependencies #659
Comments
The problem it on: return GetMaterialApp(
home: Home(), // It's close home instance
); As I mentioned in past issues, the MaterialApp home should not receive a Widget, but a widget function. There are two ways to resolve this: 2: Using named routes. You can use named routes only for the first widget, if you don't want to use named routes for the entire app: return GetMaterialApp(
getPages: [GetPage(name:'/': page:()=> Home())],
); |
Thank you for your reply, I have tested the solution you mentioned, and it did not achieve the expected effect |
The first one is OK, the second one is not OK |
@XuJin186 Can you tell us exactly what happened when you used the second option? |
Yes |
I made three questions, to which one are you answering yes? |
The second solution is the same as the previous error |
Because the oral complaint may be unclear, I also provided the test code. Please copy it and run it to see what I said. |
For me it worked when all routes are named and I replaced getPages: [
GetPage(name: '/', page: () => Home()),
GetPage(name: '/demo1', page: () => Demo1()),
GetPage(name: '/demo2', page: () => Demo2()),
], @jonataslaw this seems to be a very serious problem, because when we don't use the named routes, the controllers are not removed from memory in the |
I remembered the solution now, which was already mentioned in another issue: @override
Widget build(BuildContext context) {
final Demo2Controller _demo1controller = Get.put(Demo2Controller()); // <- here
return Scaffold(
appBar: AppBar(
title: Text("Demo2"),
),
);
} |
My answer was based on this comment from @jonataslaw: |
Thank you very much for your reply |
You're welcome @XuJin186, can this issue be closed? |
I use named routes now, so I don’t know if it can solve the problem. There must be a solution. We are only pursuing the best solution. |
Since both @jonataslaw and @eduardoflorence provided solutions and @XuJin186 started to using them, i'll close this |
Describe the bug
When using Get.to() Get uses the current path when registering dependencies, not the path you want to go
To Reproduce
Steps to reproduce the behavior:
void _registerRouteInstance<S>({String tag}) { _routesKey.putIfAbsent(_getKey(S, tag), () => Get.reference); }
检查Get.reference的值Expected behavior
void _registerRouteInstance<S>({String tag}) { _routesKey.putIfAbsent(_getKey(S, tag), () => Get.reference); }
Get.reference When it should /Demo1
Screenshots
Flutter Version:
10.0.18363.1082
Getx Version:
get: ^3.11.1
Describe on which device you found the bug:
Emulator
Minimal reproduce code
The text was updated successfully, but these errors were encountered: