navigateToSearch static method

void navigateToSearch(
  1. BuildContext context, {
  2. String? query,
})

Navigates to the search screen using go_router.

If query is provided, it will be pre-filled in the search field.

Implementation

static void navigateToSearch(BuildContext context, {String? query}) {
  if (query != null && query.isNotEmpty) {
    context.go('$searchPath?$queryParam=${Uri.encodeComponent(query)}');
  } else {
    context.go(searchPath);
  }
}