global method

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

Implementation

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

  if (_key.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 _key;
}