feat: create a dedicated provider for dashbot navigation

This commit is contained in:
Udhay-Adithya
2025-09-27 17:36:02 +05:30
parent ec02eb640f
commit b840ba44de
7 changed files with 141 additions and 99 deletions

View File

@@ -0,0 +1,22 @@
import 'package:apidash/models/models.dart';
import '../routes/dashbot_routes.dart';
/// Computes the base Dashbot route for a given request based on whether a
/// response exists.
/// - Returns [DashbotRoutes.dashbotHome] if the request has a response (either
/// statusCode or responseStatus present).
/// - Otherwise returns [DashbotRoutes.dashbotDefault].
String computeDashbotBaseRoute(RequestModel? req) {
final hasResponse = (req?.httpResponseModel?.statusCode != null) ||
(req?.responseStatus != null);
return hasResponse ? DashbotRoutes.dashbotHome : DashbotRoutes.dashbotDefault;
}
/// Returns true if the route that should be shown for [req] differs from the
/// currently active [currentRoute].
/// This helper is pure and does not perform any side effects.
bool needsDashbotRouteChange(RequestModel? req, String currentRoute) {
final target = computeDashbotBaseRoute(req);
return target != currentRoute;
}