felangel / flow_builder

Flutter Flows made easy! A Flutter package which simplifies navigation flows with a flexible, declarative API.
https://pub.dev/packages/flow_builder
MIT License
389 stars 63 forks source link

url paths? #20

Closed hansbak closed 3 years ago

hansbak commented 3 years ago

New navigator has the ability to request certain url paths....how does this work with flow builder?

thanks for the excellent open source contributions! Regards, Hans

felangel commented 3 years ago

Hi @hansbak 👋 Thanks for opening an issue!

This is something that I am currently in the process of exploring and isn't integrated into flow_builder. If you have any suggestions/ideas regarding the API/implementation I'd love to discuss them 👍

hansbak commented 3 years ago

You are so much ahead of my knowledge, at the moment i am still working on the best way implementing your Bloc combined with infinite scrolling, authorization and the best number of blocs together with the communication between them....blocs for Authorization, products,categories,orders, leads,customers suppliers etc.....All in my GrowERP project.

So now hoping you can simplify routing because version 2 is too difficult for me and web is important, therefore the paths request....

Keep up the good work, but not make things too difficult. An example is your infinite scrolling, the doc tutorial explains a much easier to understand implementation than the example implementation.

LucaDillenburg commented 3 years ago

I totally agree with @hansbak . That's really important to have in order to improve the support for the web.

The way I saw other packages implementing this is by incorporating default named routes into the package (for example the vrouter package). This works, but I think it adds unnecessary parser logic and complicates things (especially for apps that are only for iOS and Android).

What I think it's a better solution though would be to add as an optional implementation for those that want either named parameters and/or web support in a way that maintains the context.flow<T>().update or context.flow<T>().complete calls the same and changed only the onGenerateRoute by adding something like a URL parser that returned the flow state data.

For example (extending from the example in the documentation):

FlowBuilder<Profile>(
  state: const Profile(),
  onGeneratePages: (profile, pages) {
    return [
      PathMaterialPage<void>(
        child: NameForm(),
        path: '/',
        stateFromPath: (Map<String, dynamic> arguments) => profile,
      ),
      if (profile.name != null) PathMaterialPage(
        child: AgeForm()
        path: '/profile/:name',
        stateFromPath: (Map<String, dynamic> arguments) => profile.copyWith(name: arguments['name']),
      ),
    ];
  },
);

ps: In this case, PathMaterialPage would extend MaterialPage, and those two attributes (path and stateFromPath) would be added to ensure that the page can be accessed by the user if it goes directly to the URL /profile/Luca for example.

I would love to hear your thoughts and please tell me if there's something I wasn't clear on.

felangel commented 3 years ago

Proposal to add routing support can be found at https://github.com/felangel/flow_builder/issues/41.

hansbak commented 3 years ago

Excellent @felangel , thank you very much for your good work.....very much appreciated!

felangel commented 3 years ago

Closing in favor of #41 👍