forGoRouter static method

GoRouterPageBuilder forGoRouter(
  1. Widget child(
    1. BuildContext context,
    2. GoRouterState state
    ), {
  2. bool fullscreenDialog = false,
})

Implementation

static GoRouterPageBuilder forGoRouter(
  Widget Function(BuildContext context, GoRouterState state) child, {
  bool fullscreenDialog = false,
}) {
  return (BuildContext context, GoRouterState state) {
    final extra = state.extra;
    final eventProps = <String, dynamic>{};

    try {
      final props = jsonDecode(state.uri.queryParameters['eventProps'] ?? '');
      eventProps.addAll(props);
    } catch (e) {
      // ignore
    }

    if (extra is Map) {
      return _getPage(
          child: child(context, state),
          eventProps: {
            ...(extra['eventProps'] ?? {}),
            ...eventProps,
          },
          state: state,
          fullscreenDialog: fullscreenDialog);
    }
    return _getPage(
      child: child(context, state),
      eventProps: eventProps,
      state: state,
      fullscreenDialog: fullscreenDialog,
    );
  };
}