Fluro Rewrite #213
Replies: 6 comments 5 replies
-
Pattern sketch for routing. Emphasis on sketch. /// The router to exercise in this test suite
///
final routes = {
'/': {
'/user/:uid': {
'UserScaffoldPage',
false, // authRequired
{
'/profile': (_, params) => 'UserProfileTabPage(${params['uid']})',
'/photos': (_, params) => 'UserPhotosTabPage(${params['uid']})',
'/likes': (_, params) => 'UserLikesTabPage(${params['uid']})',
}
},
'/timeline': {
'TimelineScaffoldPage',
true, // authRequired
{
'/new': (_, params) => 'TimelineTabPage(TimelineSort.new)',
'/hot': (_, params) => 'TimelineTabPage(TimelineSort.hot)',
'/nearby': (_, params) => 'TimelineTabPage(TimelineSort.nearby)',
}
}
},
'/login': {
'LoginPage',
false, // authRequired
},
'/onboarding': {
'OnboardingScaffoldPage',
false, // authRequired
{
'/welcome': (_, params) => 'OnboardingWelcomeFlowPage',
'/location': (_, params) => 'OnboardingLocationFlowPage',
'/camera': (_, params) => 'OnboardingCameraFlowPage',
'/complete': (_, params) => 'OnboardingCompleteFlowPage',
}
},
'*': 'RouteNotFoundView',
};
final aliases = {
'/user/random': (context, params) => '/user/${context.randomUid}',
'/user/:uid': (context, params) => '/user/${params['uid']}/profile',
'/timeline': (context, params) => '/timeline/latest',
};
final authGuard = (context, params) {
if (context.auth.isLoggedIn == false) return '/login';
};
final redirects = {
'/onboarding/location': (context, params) {
if (context.permissions.locationIsGranted) return '/onboarding/camera';
},
'/onboarding/camera': (context, params) {
if (context.permissions.cameraIsGranted) return '/onboarding/complete';
}
}; |
Beta Was this translation helpful? Give feedback.
-
So it turns out that trying to write a massive routing package takes more than a week full time. I'm extending my time budget to add another week onto this project to see if we can get some kind of Fluro 2.0 MVP done end of next week. At this point if we can get a solid 50% of those tickets done I'd call it a win. Still working out the kinks in the routing system but the TLDR of the current status is:
Things still up in the air
I am learning very quickly that complex router packages have a lot of moving pieces and they all seem to complete around the same time. It's hard to know if you're on track until 100+ hours have been invested. This gives me a lot of sympathy for the Navigator 2.0 API which many have complained about. I also have a general concern that the push to move Flutter from mobile-only to web and desktop has caused a bit of a problem. Mobile routing is quite unique compared to web and desktop, and it seems to me that no matter which direction you go there is always going to be some platform whose experience is getting watered down. Fluro will always be mobile-first, but the API will always be intended to be multi-platform. Here's a super-early preview of how the routes/aliases and guards are constructed. Every nested level is intended for a nested router view. This would allow you to have a static AppBar that sits on top of a router that is simply a /// Redirects to `/login` if we're not authenticated
final authenticationGuard = FluroGuard((context, params) {
if (context.isAuthenticated == false) return '/login';
});
/// The router to exercise in this test suite
final router = _TestRouter(
fallbackPage: (context, params) => _stubPage('fallback page'),
aliases: [
FluroAlias(
'/user/random',
(context, params) => '/user/${context.randomUid}/profile',
),
FluroAlias(
'/user/:uid',
(context, params) => '/user/${params['uid']}/profile',
),
FluroAlias(
'/timeline',
(context, params) => '/timeline/latest',
),
FluroAlias(
'/onboarding',
(context, params) => '/onboarding/welcome',
),
],
routes: [
FluroRoute(
'/user/:uid',
page: (_, params) => _stubPage('/user/${params['uid']}'),
children: [
FluroRoute(
'/profile',
page: (_, params) => _stubPage('/profile'),
),
FluroRoute(
'/photos',
page: (_, params) => _stubPage('/photos'),
),
FluroRoute(
'/likes',
page: (_, params) => _stubPage('/likes'),
),
],
),
FluroRoute(
'/timeline',
guards: [authenticationGuard],
page: (context, params) => _stubPage('/timeline'),
children: [
FluroRoute(
'/new',
page: (context, params) => _stubPage('/new'),
),
FluroRoute(
'/hot',
page: (context, params) => _stubPage('/hot'),
),
FluroRoute(
'/nearby',
page: (context, params) => _stubPage('/nearby'),
),
],
),
FluroRoute(
'/login',
page: (context, params) => _stubPage('/login'),
),
FluroRoute(
'/onboarding',
page: (context, params) => _stubPage('/onboarding'),
children: [
FluroRoute(
'/welcome',
page: (context, params) => _stubPage('/welcome'),
),
FluroRoute(
'/location',
guards: [
FluroGuard((context, params) {
if (context.locationPermissionIsGranted)
return '/onboarding/camera';
}),
],
page: (context, params) => _stubPage('/location'),
),
FluroRoute(
'/camera',
guards: [
FluroGuard((context, params) {
if (context.cameraPermissionIsGranted)
return '/onboarding/complete';
}),
],
page: (context, params) => _stubPage('/camera'),
),
FluroRoute(
'/complete',
page: (context, params) => _stubPage('/complete'),
),
],
),
FluroRoute(
'*',
page: (context, params) => _stubPage('Route not found'),
),
],
); |
Beta Was this translation helpful? Give feedback.
-
In flight work is visible here: https://github.com/lukepighetti/fluro/tree/two/example/lib |
Beta Was this translation helpful? Give feedback.
-
It may seem odd to some that I am saying fluro will always be mobile first and yet this is clearly architected like a web router. I am currently betting that it would be much harder to build a web app with a router designed for mobile than it will be to make great mobile interactions on top of a web style router. We will see. |
Beta Was this translation helpful? Give feedback.
-
Development on Fluro is going to pause while this thread fills up with responses. flutter/uxr#4 |
Beta Was this translation helpful? Give feedback.
-
Development on Fluro 2.0 has been halted. We made some interesting progress into a nested router, but it's pretty clear to me that this is going to take a monumental amount of effort to get to a point that I'm really happy with. There is no funding available for this kind of work and I suspect that solutions will roll in as I build more Flutter apps. Eventually these may be put into a complete system. A more pressing need is to release the Fluro 1.0 null-safe version on pub. That has been released, confusingly, as Some thoughts after meeting with some of the Flutter team and thinking about this over the last few weeks.
Stacked Routing
Nested Routing
Notifications
That's all I have for now. I might update this later. |
Beta Was this translation helpful? Give feedback.
-
Development of Fluro 2.0 has begun. We plan to deliver a preview end of this week.
Fluro 2.0 will use Navigator 2.0 and be null-safe.
We're borrowing semantics from the Vue router and blending it with common Flutter patterns and tilting any opinionated solutions towards mobile routing. We probably won't complete everything in the milestone, but we're still shooting for 100% completion end of the week.
Beta Was this translation helpful? Give feedback.
All reactions