Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 56 additions & 14 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
# Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile
packages:
archive:
dependency: transitive
description:
name: archive
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.13"
args:
dependency: transitive
description:
name: args
url: "https://pub.dartlang.org"
source: hosted
version: "1.6.0"
async:
dependency: transitive
description:
Expand All @@ -22,34 +36,34 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.3"
clock:
collection:
dependency: transitive
description:
name: collection
url: "https://pub.dartlang.org"
source: hosted
version: "1.14.12"
convert:
dependency: transitive
description:
name: clock
name: convert
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.1"
collection:
version: "2.1.1"
crypto:
dependency: transitive
description:
name: collection
name: crypto
url: "https://pub.dartlang.org"
source: hosted
version: "1.14.12"
version: "2.1.4"
cupertino_icons:
dependency: "direct main"
description:
name: cupertino_icons
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.3"
fake_async:
dependency: transitive
description:
name: fake_async
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
flutter:
dependency: "direct main"
description: flutter
Expand All @@ -67,6 +81,13 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
image:
dependency: transitive
description:
name: image
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.12"
matcher:
dependency: transitive
description:
Expand All @@ -87,7 +108,21 @@ packages:
name: path
url: "https://pub.dartlang.org"
source: hosted
version: "1.7.0"
version: "1.6.4"
petitparser:
dependency: transitive
description:
name: petitparser
url: "https://pub.dartlang.org"
source: hosted
version: "2.4.0"
quiver:
dependency: transitive
description:
name: quiver
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.3"
rxdart:
dependency: "direct main"
description:
Expand Down Expand Up @@ -156,5 +191,12 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.8"
xml:
dependency: transitive
description:
name: xml
url: "https://pub.dartlang.org"
source: hosted
version: "3.6.1"
sdks:
dart: ">=2.6.0 <3.0.0"
20 changes: 13 additions & 7 deletions lib/src/modular_base.dart
Original file line number Diff line number Diff line change
Expand Up @@ -346,24 +346,30 @@ class Modular {

static Route<T> generateRoute<T>(RouteSettings settings,
[ChildModule module]) {
bool isRouterOutlet = module != null;
String path = settings.name;
Router router = selectRoute(path, module);
if (router == null) {
return null;
}
_old = Old(
args: args,
link: link,
);
if (!isRouterOutlet) {
_old = Old(
args: args,
link: link,
);
}
_args = ModularArguments(router.params, settings.arguments);

_routeLink = RouteLink(path: path, modulePath: router.modulePath);
if (!isRouterOutlet)
_routeLink = RouteLink(path: path, modulePath: router.modulePath);

if (settings.name == Modular.initialRoute) {
router = router.copyWith(transition: TransitionType.noTransition);
}

return router.getPageRoute(settings: settings, injectMap: _injectMap);
return router.getPageRoute(
settings: settings,
injectMap: _injectMap,
isRouterOutlet: isRouterOutlet);
}

static void addCoreInit(ChildModule module) {
Expand Down
24 changes: 19 additions & 5 deletions lib/src/routers/router.dart
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ class Router<T> {

Widget _disposableGenerate(BuildContext context,
{Map<String, ChildModule> injectMap,
bool isRouterOutlet,
String path,
ModularArguments args}) {
var actual = ModalRoute.of(context);
Expand All @@ -116,7 +117,9 @@ class Router<T> {
child: this.child(context, args),
dispose: () {
final List<String> trash = [];
Modular.oldProccess(_old);
if (!isRouterOutlet) {
Modular.oldProccess(_old);
}
if (actual.isCurrent) {
return;
}
Expand All @@ -138,23 +141,31 @@ class Router<T> {
}

Route<T> getPageRoute(
{Map<String, ChildModule> injectMap, RouteSettings settings}) {
{Map<String, ChildModule> injectMap,
RouteSettings settings,
bool isRouterOutlet}) {
final arguments = Modular.args.copy();

if (this.transition == TransitionType.custom &&
this.customTransition != null) {
return PageRouteBuilder(
pageBuilder: (context, _, __) {
return _disposableGenerate(context,
args: arguments, injectMap: injectMap, path: settings.name);
args: arguments,
injectMap: injectMap,
path: settings.name,
isRouterOutlet: isRouterOutlet);
},
settings: settings,
transitionsBuilder: this.customTransition.transitionBuilder,
transitionDuration: this.customTransition.transitionDuration,
);
} else if (this.transition == TransitionType.defaultTransition) {
var widgetBuilder = (context) => _disposableGenerate(context,
args: arguments, injectMap: injectMap, path: settings.name);
args: arguments,
injectMap: injectMap,
path: settings.name,
isRouterOutlet: isRouterOutlet);
if (routeGenerator != null) {
return routeGenerator(widgetBuilder, settings);
}
Expand All @@ -171,7 +182,10 @@ class Router<T> {
var selectTransition = _transitions[this.transition];
return selectTransition((context, args) {
return _disposableGenerate(context,
args: args, injectMap: injectMap, path: settings.name);
args: args,
injectMap: injectMap,
path: settings.name,
isRouterOutlet: isRouterOutlet);
}, arguments, settings);
}
}
Expand Down
62 changes: 52 additions & 10 deletions pubspec.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
# Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile
packages:
archive:
dependency: transitive
description:
name: archive
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.13"
args:
dependency: transitive
description:
name: args
url: "https://pub.dartlang.org"
source: hosted
version: "1.6.0"
async:
dependency: transitive
description:
Expand All @@ -22,27 +36,27 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.3"
clock:
collection:
dependency: transitive
description:
name: clock
name: collection
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.1"
collection:
version: "1.14.12"
convert:
dependency: transitive
description:
name: collection
name: convert
url: "https://pub.dartlang.org"
source: hosted
version: "1.14.12"
fake_async:
version: "2.1.1"
crypto:
dependency: transitive
description:
name: fake_async
name: crypto
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
version: "2.1.4"
flutter:
dependency: "direct main"
description: flutter
Expand All @@ -53,6 +67,13 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
image:
dependency: transitive
description:
name: image
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.12"
matcher:
dependency: transitive
description:
Expand All @@ -73,7 +94,21 @@ packages:
name: path
url: "https://pub.dartlang.org"
source: hosted
version: "1.7.0"
version: "1.6.4"
petitparser:
dependency: transitive
description:
name: petitparser
url: "https://pub.dartlang.org"
source: hosted
version: "2.4.0"
quiver:
dependency: transitive
description:
name: quiver
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.3"
sky_engine:
dependency: transitive
description: flutter
Expand Down Expand Up @@ -135,5 +170,12 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.8"
xml:
dependency: transitive
description:
name: xml
url: "https://pub.dartlang.org"
source: hosted
version: "3.6.1"
sdks:
dart: ">=2.6.0 <3.0.0"