Skip to content

Commit 1050043

Browse files
committed
v6.14.2
1 parent 2f4b269 commit 1050043

File tree

9 files changed

+107
-47
lines changed

9 files changed

+107
-47
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
## [6.14.2] - 2025-01-04
2+
3+
* Fix updateState method when using NyPage.path
4+
* Small fix for route guards when using redirect
5+
* Make `updatePageState` private
6+
* Update pubspec.yaml
7+
18
## [6.14.1] - 2024-12-31
29

310
* Small fix for `NyLanguageSwitcher` to support dark mode

example/pubspec.lock

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -141,10 +141,10 @@ packages:
141141
dependency: transitive
142142
description:
143143
name: error_stack
144-
sha256: ce2825abfb23ac75cb30bcf05303c714899a10a13e32058cd846058ba968576b
144+
sha256: f1f14820500d6b1931756758f8e6e899a0a0829b8b926ba04f141791cdf7b79e
145145
url: "https://pub.dev"
146146
source: hosted
147-
version: "1.9.0"
147+
version: "1.10.0"
148148
fake_async:
149149
dependency: transitive
150150
description:
@@ -231,26 +231,26 @@ packages:
231231
dependency: transitive
232232
description:
233233
name: flutter_secure_storage
234-
sha256: "165164745e6afb5c0e3e3fcc72a012fb9e58496fb26ffb92cf22e16a821e85d0"
234+
sha256: "1913841ac4c7bf57cd2e05b717e1fbff7841b542962feff827b16525a781b3e4"
235235
url: "https://pub.dev"
236236
source: hosted
237-
version: "9.2.2"
237+
version: "9.2.3"
238238
flutter_secure_storage_linux:
239239
dependency: transitive
240240
description:
241241
name: flutter_secure_storage_linux
242-
sha256: "4d91bfc23047422cbcd73ac684bc169859ee766482517c22172c86596bf1464b"
242+
sha256: bf7404619d7ab5c0a1151d7c4e802edad8f33535abfbeff2f9e1fe1274e2d705
243243
url: "https://pub.dev"
244244
source: hosted
245-
version: "1.2.1"
245+
version: "1.2.2"
246246
flutter_secure_storage_macos:
247247
dependency: transitive
248248
description:
249249
name: flutter_secure_storage_macos
250-
sha256: "1693ab11121a5f925bbea0be725abfcfbbcf36c1e29e571f84a0c0f436147a81"
250+
sha256: "6c0a2795a2d1de26ae202a0d78527d163f4acbb11cde4c75c670f3a0fc064247"
251251
url: "https://pub.dev"
252252
source: hosted
253-
version: "3.1.2"
253+
version: "3.1.3"
254254
flutter_secure_storage_platform_interface:
255255
dependency: transitive
256256
description:
@@ -411,7 +411,7 @@ packages:
411411
path: ".."
412412
relative: true
413413
source: path
414-
version: "6.14.1"
414+
version: "6.14.2"
415415
path:
416416
dependency: transitive
417417
description:

lib/controllers/ny_controller.dart

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,25 @@ class NyController extends BaseController {
1111

1212
/// Updates the page [state]
1313
/// Provide an [action] and [data] to call a method in the [NyState].
14-
void updatePageState(String action, dynamic data) {
14+
void _updatePageState(String action, dynamic data) {
1515
assert(state != null, "State cannot be null");
1616
if (state == null) return;
1717
updateState(state!, data: {"action": action, "data": data});
1818
}
1919

2020
/// Refreshes the page
2121
refreshPage() {
22-
updatePageState("refresh-page", {"setState": () {}});
22+
_updatePageState("refresh-page", {"setState": () {}});
2323
}
2424

2525
/// Set the state of the page
2626
setState({required Function() setState}) {
27-
updatePageState("set-state", {"setState": setState});
27+
_updatePageState("set-state", {"setState": setState});
2828
}
2929

3030
/// Pop the page
3131
pop({dynamic result}) {
32-
updatePageState("pop", {"result": result});
32+
_updatePageState("pop", {"result": result});
3333
}
3434

3535
/// Displays a Toast message containing "Sorry" for the title, you
@@ -38,7 +38,7 @@ class NyController extends BaseController {
3838
{String? title,
3939
required String description,
4040
ToastNotificationStyleType? style}) {
41-
updatePageState("toast-sorry", {
41+
_updatePageState("toast-sorry", {
4242
"title": title ?? "Sorry",
4343
"description": description,
4444
"style": style ?? ToastNotificationStyleType.danger
@@ -51,7 +51,7 @@ class NyController extends BaseController {
5151
{String? title,
5252
required String description,
5353
ToastNotificationStyleType? style}) {
54-
updatePageState("toast-warning", {
54+
_updatePageState("toast-warning", {
5555
"title": title ?? "Warning",
5656
"description": description,
5757
"style": style ?? ToastNotificationStyleType.warning
@@ -64,7 +64,7 @@ class NyController extends BaseController {
6464
{String? title,
6565
required String description,
6666
ToastNotificationStyleType? style}) {
67-
updatePageState("toast-info", {
67+
_updatePageState("toast-info", {
6868
"title": title ?? "Info",
6969
"description": description,
7070
"style": style ?? ToastNotificationStyleType.info
@@ -77,7 +77,7 @@ class NyController extends BaseController {
7777
{String? title,
7878
required String description,
7979
ToastNotificationStyleType? style}) {
80-
updatePageState("toast-danger", {
80+
_updatePageState("toast-danger", {
8181
"title": title ?? "Error",
8282
"description": description,
8383
"style": style ?? ToastNotificationStyleType.danger
@@ -90,7 +90,7 @@ class NyController extends BaseController {
9090
{String? title,
9191
required String description,
9292
ToastNotificationStyleType? style}) {
93-
updatePageState("toast-oops", {
93+
_updatePageState("toast-oops", {
9494
"title": title ?? "Oops",
9595
"description": description,
9696
"style": style ?? ToastNotificationStyleType.danger
@@ -103,7 +103,7 @@ class NyController extends BaseController {
103103
{String? title,
104104
required String description,
105105
ToastNotificationStyleType? style}) {
106-
updatePageState("toast-success", {
106+
_updatePageState("toast-success", {
107107
"title": title ?? "Success",
108108
"description": description,
109109
"style": style ?? ToastNotificationStyleType.success
@@ -115,7 +115,7 @@ class NyController extends BaseController {
115115
{String? title,
116116
required String description,
117117
ToastNotificationStyleType? style}) {
118-
updatePageState("toast-custom", {
118+
_updatePageState("toast-custom", {
119119
"title": title ?? "",
120120
"description": description,
121121
"style": style ?? ToastNotificationStyleType.custom
@@ -134,7 +134,7 @@ class NyController extends BaseController {
134134
required Function()? onSuccess,
135135
Function(Exception exception)? onFailure,
136136
String? lockRelease}) {
137-
updatePageState("validate", {
137+
_updatePageState("validate", {
138138
"rules": rules,
139139
"data": data,
140140
"messages": messages,
@@ -149,7 +149,7 @@ class NyController extends BaseController {
149149

150150
/// Update the language in the application
151151
void changeLanguage(String language, {bool restartState = true}) {
152-
updatePageState("change-language", {
152+
_updatePageState("change-language", {
153153
"language": language,
154154
"restartState": restartState,
155155
});
@@ -158,14 +158,14 @@ class NyController extends BaseController {
158158
/// Perform a lock release
159159
void lockRelease(String name,
160160
{required Function perform, bool shouldSetState = true}) async {
161-
updatePageState("lock-release",
161+
_updatePageState("lock-release",
162162
{"name": name, "perform": perform, "shouldSetState": shouldSetState});
163163
}
164164

165165
/// Perform a confirm action
166166
void confirmAction(Function() action,
167167
{required String title, String dismissText = "Cancel"}) async {
168-
updatePageState("confirm-action",
168+
_updatePageState("confirm-action",
169169
{"action": action, "title": title, "dismissText": dismissText});
170170
}
171171
}

lib/helpers/helper.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -377,8 +377,7 @@ void updateState<T>(dynamic name,
377377
}
378378
if (name is RouteView) {
379379
stateName =
380-
"${name.$2.runtimeType.toString().replaceAll("BuildContext", "")}State"
381-
.replaceAll("() => ", "() => _");
380+
"Closure: ${"${name.$2.runtimeType.toString().replaceAll("BuildContext", "")}State".replaceAll("() => ", "() => _")}";
382381
}
383382

384383
final event = UpdateState(data: dataUpdate, stateName: stateName);

lib/router/models/nyrouter_route_guard.dart

Lines changed: 57 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ class NyRouteGuard extends RouteGuard {
8181
if (data != null) {
8282
currentData = data;
8383
}
84-
routeTo(path,
84+
85+
return PageRequest.redirect(path,
8586
data: currentData,
8687
queryParameters: queryParameters,
8788
navigationType: navigationType,
@@ -90,7 +91,6 @@ class NyRouteGuard extends RouteGuard {
9091
pageTransitionSettings: pageTransitionSettings,
9192
pageTransitionType: pageTransitionType,
9293
onPop: onPop);
93-
return PageRequest.redirect();
9494
}
9595
}
9696

@@ -100,18 +100,72 @@ class PageRequest {
100100
NyArgument? nyArgument;
101101
Map<String, String>? queryParameters;
102102
bool isRedirect = false;
103+
RouteData? routeData;
103104

104105
get data => nyArgument?.data;
105106

106107
PageRequest({this.context, this.nyArgument, this.queryParameters});
107108

108109
/// Redirect to a new route.
109-
PageRequest.redirect() {
110+
PageRequest.redirect(dynamic path,
111+
{dynamic data,
112+
Map<String, dynamic>? queryParameters,
113+
NavigationType navigationType = NavigationType.pushReplace,
114+
dynamic result,
115+
bool Function(Route<dynamic> route)? removeUntilPredicate,
116+
PageTransitionSettings? pageTransitionSettings,
117+
PageTransitionType? pageTransitionType,
118+
Function(dynamic value)? onPop}) {
110119
isRedirect = true;
120+
routeData = RouteData(path,
121+
data: data,
122+
queryParameters: queryParameters,
123+
navigationType: navigationType,
124+
result: result,
125+
removeUntilPredicate: removeUntilPredicate,
126+
pageTransitionSettings: pageTransitionSettings,
127+
pageTransitionType: pageTransitionType,
128+
onPop: onPop);
111129
}
112130

113131
/// Add data to the current route.
114132
addData(dynamic Function(dynamic data) currentData) {
115133
nyArgument?.setData((currentData(data)));
116134
}
117135
}
136+
137+
/// Route data class.
138+
class RouteData {
139+
dynamic path;
140+
dynamic data;
141+
Map<String, dynamic>? queryParameters;
142+
NavigationType navigationType = NavigationType.pushReplace;
143+
dynamic result;
144+
bool Function(Route<dynamic> route)? removeUntilPredicate;
145+
PageTransitionSettings? pageTransitionSettings;
146+
PageTransitionType? pageTransitionType;
147+
Function(dynamic value)? onPop;
148+
149+
RouteData(this.path,
150+
{this.data,
151+
this.queryParameters,
152+
this.navigationType = NavigationType.pushReplace,
153+
this.result,
154+
this.removeUntilPredicate,
155+
this.pageTransitionSettings,
156+
this.pageTransitionType,
157+
this.onPop});
158+
159+
/// Redirect to a new route.
160+
routeToPage() async {
161+
await routeTo(path,
162+
data: data,
163+
queryParameters: queryParameters,
164+
navigationType: navigationType,
165+
result: result,
166+
removeUntilPredicate: removeUntilPredicate,
167+
pageTransitionSettings: pageTransitionSettings,
168+
pageTransitionType: pageTransitionType,
169+
onPop: onPop);
170+
}
171+
}

lib/widgets/ny_base_state.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,10 @@ abstract class NyBaseState<T extends StatefulWidget> extends State<T> {
588588
} on Exception catch (e) {
589589
NyLogger.error(e.toString());
590590
}
591-
hasInitComplete = true;
591+
if (widget is NyStatefulWidget &&
592+
(widget as NyStatefulWidget).controller.routeGuards.isEmpty) {
593+
hasInitComplete = true;
594+
}
592595
_updateLoadingState(
593596
shouldSetState: shouldSetStateAfter, name: name, value: false);
594597
}

lib/widgets/ny_page.dart

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,9 @@ abstract class NyPage<T extends StatefulWidget> extends NyBaseState<T> {
8787
if (pageRequestFromRouteGuard?.isRedirect == true) {
8888
routeGuardsPassed = false;
8989
}
90-
if (pageRequestFromRouteGuard?.data != null) {
91-
(widget as NyStatefulWidget)
92-
.controller
93-
.request
94-
?.setData(pageRequestFromRouteGuard?.data);
95-
}
90+
WidgetsBinding.instance.addPostFrameCallback((_) {
91+
pageRequestFromRouteGuard?.routeData?.routeToPage();
92+
});
9693
}
9794
if (!routeGuardsPassed) {
9895
return;

pubspec.lock

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -141,10 +141,10 @@ packages:
141141
dependency: "direct main"
142142
description:
143143
name: error_stack
144-
sha256: ce2825abfb23ac75cb30bcf05303c714899a10a13e32058cd846058ba968576b
144+
sha256: f1f14820500d6b1931756758f8e6e899a0a0829b8b926ba04f141791cdf7b79e
145145
url: "https://pub.dev"
146146
source: hosted
147-
version: "1.9.0"
147+
version: "1.10.0"
148148
fake_async:
149149
dependency: transitive
150150
description:
@@ -239,26 +239,26 @@ packages:
239239
dependency: "direct main"
240240
description:
241241
name: flutter_secure_storage
242-
sha256: "165164745e6afb5c0e3e3fcc72a012fb9e58496fb26ffb92cf22e16a821e85d0"
242+
sha256: "1913841ac4c7bf57cd2e05b717e1fbff7841b542962feff827b16525a781b3e4"
243243
url: "https://pub.dev"
244244
source: hosted
245-
version: "9.2.2"
245+
version: "9.2.3"
246246
flutter_secure_storage_linux:
247247
dependency: transitive
248248
description:
249249
name: flutter_secure_storage_linux
250-
sha256: "4d91bfc23047422cbcd73ac684bc169859ee766482517c22172c86596bf1464b"
250+
sha256: bf7404619d7ab5c0a1151d7c4e802edad8f33535abfbeff2f9e1fe1274e2d705
251251
url: "https://pub.dev"
252252
source: hosted
253-
version: "1.2.1"
253+
version: "1.2.2"
254254
flutter_secure_storage_macos:
255255
dependency: transitive
256256
description:
257257
name: flutter_secure_storage_macos
258-
sha256: "1693ab11121a5f925bbea0be725abfcfbbcf36c1e29e571f84a0c0f436147a81"
258+
sha256: "6c0a2795a2d1de26ae202a0d78527d163f4acbb11cde4c75c670f3a0fc064247"
259259
url: "https://pub.dev"
260260
source: hosted
261-
version: "3.1.2"
261+
version: "3.1.3"
262262
flutter_secure_storage_platform_interface:
263263
dependency: transitive
264264
description:

pubspec.yaml

Lines changed: 3 additions & 3 deletions
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.14.1
3+
version: 6.14.2
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
@@ -16,7 +16,7 @@ environment:
1616
flutter: ">=3.24.0"
1717

1818
dependencies:
19-
flutter_secure_storage: ^9.2.2
19+
flutter_secure_storage: ^9.2.3
2020
flutter_dotenv: ^5.2.1
2121
theme_provider: ^0.6.0
2222
validated: ^2.0.0
@@ -32,7 +32,7 @@ dependencies:
3232
pretty_dio_logger: ^1.4.0
3333
intl: ^0.19.0
3434
skeletonizer: ^1.4.1+1
35-
error_stack: ^1.9.0
35+
error_stack: ^1.10.0
3636
date_field: ^6.0.0
3737
flutter_multi_formatter: ^2.13.0
3838
flutter_local_notifications: ^18.0.1

0 commit comments

Comments
 (0)