FilledStacks / flutter-tutorials

The repo contains the source code for all the tutorials on the FilledStacks Youtube channel.
MIT License
4.74k stars 1.76k forks source link

Passing arguments with AutoRouter #102

Open kenyons opened 4 years ago

kenyons commented 4 years ago

Can the AutoRouter still be used when arguments are passed? I see how it is done manually in router of the navigation tutorial, but using the AutoRouter, the argument is not passed to the new view. Can you update the navigation example to use the new stacked_services package?

FilledStacks commented 4 years ago

auto_route generates an argument class that you should use. It serialises it automatically. it's [ViewName]Arguments so if your view is called HomeView you should pass HomeViewArguments as your arguments when calling navigate. It will automatically serialise and pass that to your view

kenyons commented 4 years ago

Thanks, I had seen the arguments class generated for the HomeView, but had to run the build a couple of times for the other to show up for some reason.

One other question. Any suggested way to architect a view that is basically a wrapper for a WebView in moving to the view/viewmodel architecture? Right now I have just added a method on the viewmodel to be passed to the WebResourceErrorCallback on the WebView. Doesn't seem to be a way to handle the HTTP request in the viewmodel and pass it to the WebView.

FilledStacks commented 4 years ago

@kenyons I don't think you can "pass" anything to the webview. You can listen for route changes on the webview and tell it where to navigate but other than that I don't think you can pass anything to the webview.