openPage<T> method

Future<T?>? openPage<T>(
  1. BuildContext context,
  2. String pageName, {
  3. RoutePushType pushType = RoutePushType.pushNamed,
  4. Map? arguments,
  5. RoutePredicate? predicate,
})

open page

Implementation

Future<T?>? openPage<T>(BuildContext context, String pageName,
    {RoutePushType pushType = RoutePushType.pushNamed,
    Map<dynamic, dynamic>? arguments,
    RoutePredicate? predicate}) {
  Map<String, dynamic> args = {'args': arguments};
  switch (pushType) {
    case RoutePushType.pushNamed:
      return Navigator.pushNamed(context, pageName, arguments: args);
    case RoutePushType.pushReplacementNamed:
      return Navigator.pushReplacementNamed(context, pageName,
          arguments: args);
    case RoutePushType.popAndPushNamed:
      return Navigator.popAndPushNamed(context, pageName, arguments: args);
    case RoutePushType.pushAndRemoveUntil:
      assert(predicate != null);
      return Navigator.pushNamedAndRemoveUntil(
        context,
        pageName,
        predicate!,
        arguments: args,
      );
  }
}