Skip to content

Commit 4c9bab9

Browse files
authored
Merge pull request #126 from nubank/nuvigator/add-optional-builder
[feature] add optional builder to Nuvigator and NuvigatorState
2 parents 59d468b + 3a49a24 commit 4c9bab9

3 files changed

Lines changed: 14 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# CHANGELOG
22

3+
## 2.0.1
4+
- Add optional TransitionBuilder to Nuvigator to allow nesting additional Widgets on the tree
5+
36
## 2.0.0
47
- Remove deprecated hash function to support Flutter 3.27
58

lib/src/nuvigator.dart

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ class _NuvigatorInner<T extends INuRouter> extends Navigator {
8787
this.debug = false,
8888
this.inheritableObservers = const [],
8989
this.shouldPopRoot = false,
90+
this.builder,
9091
}) : super(
9192
observers: [
9293
HeroController(),
@@ -123,6 +124,7 @@ class _NuvigatorInner<T extends INuRouter> extends Navigator {
123124
final ScreenType screenType;
124125
final WrapperFn? wrapper;
125126
final List<ObserverBuilder> inheritableObservers;
127+
final TransitionBuilder? builder;
126128

127129
@override
128130
NavigatorState createState() {
@@ -493,7 +495,11 @@ class NuvigatorState<T extends INuRouter> extends NavigatorState
493495
child: child,
494496
);
495497
}
496-
return child;
498+
final builder = widget.builder;
499+
500+
return builder != null
501+
? Builder(builder: (context) => builder(context, child))
502+
: child;
497503
}
498504
}
499505

@@ -512,6 +518,7 @@ class Nuvigator<T extends INuRouter?> extends StatelessWidget {
512518
this.inheritableObservers = const [],
513519
this.shouldPopRoot = false,
514520
this.shouldRebuild,
521+
this.builder,
515522
}) : _innerKey = key,
516523
assert(router != null);
517524

@@ -551,6 +558,7 @@ class Nuvigator<T extends INuRouter?> extends StatelessWidget {
551558
final Key? _innerKey;
552559
final Map<String, dynamic>? initialArguments;
553560
final ShouldRebuildFn? shouldRebuild;
561+
final TransitionBuilder? builder;
554562

555563
/// Maybe fetches a [NuvigatorState] from the current BuildContext.
556564
static NuvigatorState<T>? maybeOf<T extends INuRouter>(
@@ -604,6 +612,7 @@ class Nuvigator<T extends INuRouter?> extends StatelessWidget {
604612
router: router as NuRouter,
605613
shouldRebuild: shouldRebuild,
606614
builder: (moduleRouter) => _NuvigatorInner(
615+
builder: builder,
607616
router: moduleRouter,
608617
debug: debug,
609618
inheritableObservers: inheritableObservers,

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: nuvigator
22
description: A powerful routing abstraction over Flutter navigator, providing some new features and an easy way to define routers.
3-
version: 2.0.0
3+
version: 2.0.1
44

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

0 commit comments

Comments
 (0)