brianegan / new_flutter_template

Test ideas for a new flutter template
140 stars 23 forks source link

What kind of Routing should be supported? #6

Open brianegan opened 3 years ago

brianegan commented 3 years ago

Assuming we work with a list view / detail view application, what kind of routing should the template employ? Should it worry about Flutter Web urls? Should it have some url parsing to demonstrate the concept? Should it use simple Navigator.push? What is important for routing in a template?

Please note: we've been asked to hold off on Navigator 2.0 for now.

MarkOSullivan94 commented 3 years ago

Please note: we've been asked to hold off on Navigator 2.0 for now.

Out of interest, why?

brianegan commented 3 years ago

@MarkOSullivan94 Unfortunately the information way conveyed to me second-hand and I don't want to put any words in the mouths of the Flutter team. Perhaps @filiph has the specifics.

From my perspective, we learned by writing the evaluations that getting a basic version going of Navigator 2.0 requires a decent amount of code & introduces a few new concepts, which seemed like it could be overwhelming to our target audience.

rrousselGit commented 3 years ago

I can only agree with the decision to not use Navigator 2.0 in the template

So far all the discussions point out that it targets package authors instead of end users

Arkangel12 commented 3 years ago

This should be a good starting point:

But also maybe it could add a way to let them know this one is a really good option and how this could be implemented:

I do agree about holding Navigator 2.0 for now.

sbis04 commented 3 years ago

This seems to be the best routing technique to have as a template initially:

Using onGenerateRoute also takes care of the URL navigation of the Flutter web.

VictorUvarov commented 3 years ago

What about static routes on each page? I used to use onGenerateRoute but not having the type safety for arguments was a deal breaker. This solution was first introduced by Simon Lightfoot at Flutter Europe

class DetailsPage extends StatelessWidget {
  static Route route(DetailsPageParams params) {
    return MaterialPageRoute<void>(
      builder: (_) => DetailsPage(params: params),
      settings: RouteSettings(
        name: 'DetailsPage',
        arguments: params,
      ),
    );
  }

 const DetailsPage({Key key, @required DetailsPageParams params}) : super(key: key);

 final DetailsPageParams params;
 ...
}

Usage:

Navigator.of(context).push(DetailsPage.route(DetailsPageParams(...)));