currentArgs property

Map<String, dynamic>? get currentArgs

Retrieves the arguments passed to the current route.

Returns a Map of arguments or null if no arguments were passed.

Implementation

Map<String, dynamic>? get currentArgs {
  try {
    if (context != null) {
      final args = ModalRoute.of(context!)?.settings.arguments
          as Map<String, dynamic>?;
      return args;
    } else if (navigatorKey != null) {
      if (navigatorObserver.topRoute != null) {
        final args = navigatorObserver.topRoute!.settings.arguments
            as Map<String, dynamic>?;
        return args;
      }
    }
  } catch (e) {
    print('Error in currentArgs: $e');
  }
  return null;
}