csells / go_router

The purpose of the go_router for Flutter is to use declarative routes to reduce complexity, regardless of the platform you're targeting (mobile, web, desktop), handling deep linking from Android, iOS and the web while still allowing an easy-to-use developer experience.
https://gorouter.dev
442 stars 96 forks source link

add a GoRouter.builder ctor #36

Closed csells closed 2 years ago

csells commented 3 years ago

it should take two functions:

  1. a navigate function that does the redirection and builds up the stack of page builders
  2. a builder function that creates the Navigator with the stack of pages from the page builders
GoRouter.builder(
  String Function(String location) navigate, // returns whatever loc redirection lands on
  Widget Function(BuildContext context, String location) builder, // builds the Navigator
)

// the delegate implementation becomes easy now
void go(String location) {
  _loc = this.navigate(location);
  notifyListeners(); // calls build()
}

Widget build(BuildContext context) => this.builder(context);

That's what the real API is for Nav2 and on top of that can be built the declarative routing solution that's in place now.