get<T extends Object> static method

Future<T?> get<T extends Object>({
  1. required String path,
  2. BuildContext? context,
  3. dynamic data,
})

Implementation

static Future<T?> get<T extends Object>(
    {required String path, BuildContext? context, dynamic data}) async {
  context ??= OdinApp.get().getNavigatorKey().currentContext;

  if (context == null) {
    return null;
  }
  dynamic result;
  if (_routes[path]['type'] == OdinNavigatorRouteType.modal) {
    result = await OdinNavigatorModal.open<T>(
        backgroundColor: _routes[path]['background_color'],
        context: context,
        child: _routes[path]['callback'](context, data));
  } else {
    result = await OdinNavigatorPage.open<T>(
        forceFullPage: _routes[path]['force_full_page'] ?? false,
        backgroundColor: _routes[path]['background_color'],
        context: context,
        child: _routes[path]['callback'](context, data));
  }

  dynamic onDone = _routes[path]['on_done'];

  if (onDone != null) {
    await onDone();
  }

  Controller.refreshAll();

  return result;
}