I have this route
Get.toNamed('/community/discussion/${controller.community.topicId}}');
While navigating to the view, I want to pass the route parameter topicId
to the view's controller so that it uses as document ID and load the content which will be stream to the view.
How can I send this parameter to the controller before the view's content is streamed?
I guess you're not using Get.toNamed
the way it is supposed to.
Function toNamed
takes a dynamic
parameter arguments
that you can use for your purpose.
In your source screen:
Get.toNamed<void>("/community/discussion/",
arguments: {"topicId": controller.community.topicId});
In your destination screen:
var topicId = Get.parameters['topicId'];
Then you can easily set the topic id into your controller:
controller.topicId = topicId;
class YourController extends GetxController {
int? topicId;
}