Skip to content

Commit 613962f

Browse files
committed
v6.31.0
1 parent 8a64649 commit 613962f

File tree

7 files changed

+29
-3
lines changed

7 files changed

+29
-3
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## [6.31.0] - 2025-06-23
2+
3+
* Added `set` to NySession class. This will allow you to set a value in the session.
4+
* Added `onFailure` parameter to isSuccessful method in `NyValidator`.
5+
* Fix `getInitialRouteName` to return the correct initial route name when, `when` is used.
6+
17
## [6.30.0] - 2025-06-23
28

39
* Added `PullableConfig` to pullable widget.

example/pubspec.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ packages:
419419
path: ".."
420420
relative: true
421421
source: path
422-
version: "6.30.0"
422+
version: "6.31.0"
423423
path:
424424
dependency: transitive
425425
description:

lib/helpers/ny_session.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ class NySession {
2323
return this;
2424
}
2525

26+
/// Set a value in the session
27+
NySession set(String key, dynamic value) {
28+
return add(key, value);
29+
}
30+
2631
/// Get a value from the session
2732
T? get<T>(String key) {
2833
return Backpack.instance.sessionGet<T>(name, key);

lib/router/models/nyrouter_route.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ class NyRouterRoute {
3030
PageTransitionSettings? pageTransitionSettings;
3131
bool _initialRoute, _authPage, _unknownRoute;
3232
final List<RouteGuard> _routeGuards = [];
33+
Function()? _when;
3334

3435
NyRouterRoute(
3536
{required this.name,
@@ -106,6 +107,7 @@ class NyRouterRoute {
106107

107108
/// Set the initial route.
108109
NyRouterRoute initialRoute({bool Function()? when}) {
110+
_when = when;
109111
if (when != null && when()) {
110112
_initialRoute = true;
111113
}
@@ -136,6 +138,7 @@ class NyRouterRoute {
136138

137139
/// Set the authenticated route.
138140
NyRouterRoute authenticatedRoute({bool Function()? when}) {
141+
_when = when;
139142
if (when != null && when()) {
140143
_authPage = true;
141144
}
@@ -164,4 +167,9 @@ class NyRouterRoute {
164167
List<RouteGuard> getRouteGuards() {
165168
return _routeGuards;
166169
}
170+
171+
/// Get the when function.
172+
bool getWhen() {
173+
return _when != null ? _when!() : true;
174+
}
167175
}

lib/router/router.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,8 @@ class NyRouter {
499499
String getInitialRouteName() {
500500
List<MapEntry<String, NyRouterRoute>> initialRoutes = NyNavigator
501501
.instance.router._routeNameMappings.entries
502-
.where((element) => element.value.getInitialRoute() == true)
502+
.where((element) =>
503+
element.value.getInitialRoute() == true && element.value.getWhen())
503504
.toList();
504505

505506
if (initialRoutes.isNotEmpty) {

lib/validation/ny_validator.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ class NyValidator {
9797
static bool isSuccessful({
9898
required Map<String, dynamic> rules,
9999
Map<String, dynamic>? data,
100+
Function(ValidationException error)? onFailure,
100101
}) {
101102
Map<String, String> finalRules = {};
102103
Map<String, dynamic> finalData = {};
@@ -125,6 +126,11 @@ class NyValidator {
125126
);
126127

127128
return true;
129+
} on ValidationException catch (e) {
130+
if (onFailure != null) {
131+
onFailure(e);
132+
}
133+
return false;
128134
} on Exception catch (_) {
129135
return false;
130136
}

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: nylo_support
22
description: Support library for the Nylo framework. This library supports routing, widgets, localization, cli, storage and more.
3-
version: 6.30.0
3+
version: 6.31.0
44
homepage: https://nylo.dev
55
repository: https://github.com/nylo-core/support/tree/6.x
66
issue_tracker: https://github.com/nylo-core/support/issues

0 commit comments

Comments
 (0)