Skip to content

Commit

Permalink
Merge pull request #96 from nubank/revert-1.6.1
Browse files Browse the repository at this point in the history
Revert 1.6.1
  • Loading branch information
leoiacovini authored May 5, 2022
2 parents aecb79b + 1ff7c28 commit 9d810b9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# CHANGELOG

## 1.6.2
- [FIX] Revert changes from 1.6.1 due to some unexpected behaviors found

## 1.6.1
- [FIX] Fix re-renders due to other state changes when `Nuvigator.shouldRebuild` returns false

Expand Down
15 changes: 8 additions & 7 deletions lib/src/next/v1/nu_router.dart
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ class NuRouterLoader extends StatefulWidget {
}

class _NuRouterLoaderState extends State<NuRouterLoader> {
NuRouter router;
Widget nuvigator;
bool loading;
Widget errorWidget;

Expand All @@ -437,16 +437,15 @@ class _NuRouterLoaderState extends State<NuRouterLoader> {

Future<void> _initModule() async {
setState(() {
router = widget.router;
loading = router.awaitForInit;
loading = widget.router.awaitForInit;
errorWidget = null;
});
try {
await router._init(context);
await widget.router._init(context);
} catch (error, stackTrace) {
debugPrintStack(stackTrace: stackTrace, label: error.toString());
final errorWidget =
router.onError(error, NuRouterController(reload: _reload));
widget.router.onError(error, NuRouterController(reload: _reload));
if (errorWidget != null) {
setState(() {
this.errorWidget = errorWidget;
Expand All @@ -463,6 +462,7 @@ class _NuRouterLoaderState extends State<NuRouterLoader> {
void didUpdateWidget(covariant NuRouterLoader oldWidget) {
if (widget.shouldRebuild(oldWidget.router, widget.router)) {
_initModule();
nuvigator = widget.builder(widget.router);
}
super.didUpdateWidget(oldWidget);
}
Expand All @@ -476,10 +476,11 @@ class _NuRouterLoaderState extends State<NuRouterLoader> {
@override
Widget build(BuildContext context) {
if (loading) {
return router.loadingWidget;
return widget.router.loadingWidget;
} else if (errorWidget != null) {
return errorWidget;
}
return widget.builder(router);
nuvigator ??= widget.builder(widget.router);
return nuvigator;
}
}
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: nuvigator
description: A powerful routing abstraction over Flutter navigator, providing some new features and an easy way to define routers.
version: 1.6.1
version: 1.6.2

homepage: https://github.com/nubank/nuvigator

Expand Down

0 comments on commit 9d810b9

Please sign in to comment.