global method

GlobalKey<NavigatorState> global(
  1. int? k
)

Implementation

GlobalKey<NavigatorState> global(int? k) {
  GlobalKey<NavigatorState> newKey;
  if (k == null) {
    newKey = key;
  } else {
    if (!keys.containsKey(k)) {
      throw 'Route id ($k) not found';
    }
    newKey = keys[k]!;
  }

  if (newKey.currentContext == null && !testMode) {
    throw """You are trying to use contextless navigation without
    a GetMaterialApp or Get.key.
    If you are testing your app, you can use:
    [Get.testMode = true], or if you are running your app on
    a physical device or emulator, you must exchange your [MaterialApp]
    for a [GetMaterialApp].
    """;
  }

  return newKey;
}