Flutter Navigator default route route in Fluro package - flutter

I am using Flutter with Fluro package and I want to set a default route for the app.
The need is to have a place to decide which path the user needs to navigate to, and from there to navigate the app by whatever settings decided upon.
Currently, I defined the routes in the app and do have a "404" (not found) route as described in the docs of the package, but I prefer to have another way which is more correct to solve it.
For example, the app has the routes:
"homepage"
"splash_screen"
"search"
"not_found"
"init"
I want the route init to be the default one.
Thank you,
Nisim

After digging some more I found the Fluro package has internal class RouteTree which handles all routes. when adding a new route it will check if it defaults by comparing it to Navigator.defaultRouteName (value "/").
Note: it allow you to add only one default route and will throw an exception if you do it more then one.
Adding the default route with handler solved the issue and now the default route is the one deciding about the next route and displays something in the meantime.

Related

How to print the current route path in flutter using auto_router?

I have been using auto_route in my flutter app for navigation. I'm wondering if there's any way to print the current route path (example: /home/profile...). It'll be of great help while debugging and managing the routes.
Is there any way to do it?
It's a very simple implementation, just use this line
print(context.router.currentPath);
By below line you can get curent route:
ModalRoute.of(context).settings.name

API Controller Routing in .NET 6 Doesn't Work Any More

I'm trying to create a standard WebAPI project in .NET 6. I notice that the standard ApiController route doesn't have the leading api route that I like to have. When I add it, the controller breaks. It doesn't give me a 404 (not found), it just gives me that index page that says that I have to enable javascript. I'm really at a loss at what I have to do to make my app work where I can put api at the start of my routes:
[Route("api/[controller]")]
I've tried adding it to the default controller route map in different combinations. I've tried adding the UseEndpoints method in the Program class. I'm just not sure what to differently in 6.
For those who want to "see my code", I'm just using the standard WebAPI project w/ React (NO Redux!).
Check the new setupProxy.js file image description inside the ClientApp folder, you need to configure the backend routes in the proxy config, I had a similar issue with the ASP.NET Core 6.0 with Angular project template, you can find more information here link 1 link 2

How to redirect to error page, If the URL is invalid?

I am beginner to play scala framework. And I have created simple CRUD operation using it.
In my routes file I have declared all the necesary urls for different actions.
I want to know if user input some wrong url path from browser How should I display error page in play scala? Right now I am getting all the routes which are already defined.
I just found a solution for it
https://www.playframework.com/documentation/2.8.x/ScalaErrorHandling
this is the latest play scala documentation which handles such type of condition.
Since I am using runtime dependency injection (e.g. Guice), the error handler can be dynamically loaded at runtime.
The simplest way is to create a class in the root package called ErrorHandler that implements HttpErrorHandler.
If you place your error handler in the root package (i.e. package-less) and name it ErrorHandler, Play will use it by default.
But, in case you want to:
Add it inside a package;
Configure different error handlers for different environments;
Then add in application.conf the configuration property play.http.errorHandler pointing to your custom error handler class:
play.http.errorHandler = "com.example.ErrorHandler"

How to perform Deep-linking with Flutter Web?

Flutter Web: Is there a way to make the URLs for an app appear similar to the navigation route name so that we can do deep linking? For e.g. if I run an app now on chrome, the URL I get is "http://localhost:51322/#/". So if I am on the home screen, how can I have it as "http://localhost:51322/#/home"?
I tried the solution at https://medium.com/flutter-community/more-than-a-flutter-web-app-is-a-full-flutter-website-c6bb210b1f16, but it doesn't seem to work anymore.
The section of the url after the # is the "route name" from "named routes" which are explained pretty well here: https://flutter.dev/docs/cookbook/navigation/named-routes
Specifically to change from "/" to "/home" as your default route, you want to change the "initialRoute" parameter to MaterialApp to "/home" and make sure your routes map has an entry for "/home" instead of "/"
There are a few ways to tell MaterialApp what the "home" or "root" Widget is, you will want to be careful that you don't give it conflicting instructions. The specifics are in the class documentation: https://api.flutter.dev/flutter/material/MaterialApp-class.html

Defining a route inside a lumen package

I'm working on a Lumen package. In this package I have to define 2 routes for webhooks. What I did is create a routes file, load that through loadRoutesFrom() in my package's service provider, and in the routes file, I defined the route like this:
$this->app->get("/webhooks/decision", \YoungOnes\ArtisanVeriff\Commands\DecisionWebhookCommand::class);
I saw this in an article somewhere as a valid solution, especially since I can't use the routes class. However, when I run this, I get the following:
EntryNotFoundException
/webhooks/decision
How do I define a route from within a Lumen package?
I tried this - it seems to work:
$this->app->router->get()