back static method

void back({
  1. int count = 1,
  2. Object? arguments,
})

back to the previous page 无context返回,并指定路由返回多少层,默认返回上一页面, 返回带参数params

count The number of pages to pop from the stack (default is 1). arguments Optional data to pass back to the previous route.

Returns a Future that completes when the popped route is removed.

Implementation

static void back({int count = 1, Object? arguments}) {
  NavigatorState state = Navigator.of(HbRouter.key.currentContext!);
  while (count-- > 0) {
    if (state.canPop()) {
      if (HbRouter.history.isNotEmpty) HbRouter.history.removeLast();
      state = state..pop(arguments);
    }
  }
}