Skip to content

Commit e416ed6

Browse files
committed
+Add StatefulRouteManager
1 parent 6f66c1d commit e416ed6

5 files changed

Lines changed: 106 additions & 24 deletions

File tree

README.md

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
1-
<a href="https://www.buymeacoffee.com/dev_cetera" target="_blank"><img align="right" src="https://cdn.buymeacoffee.com/buttons/default-orange.png" height="48"></a>
2-
<a href="https://discord.gg/gEQ8y2nfyX" target="_blank"><img align="right" src="https://raw.githubusercontent.com/dev-cetera/.github/refs/heads/main/assets/icons/discord_icon/discord_icon.svg" height="48"></a>
1+
[![banner](https://github.com/dev-cetera/df_router/blob/v0.4.15/doc/assets/banner.png?raw=true)](https://github.com/dev-cetera)
32

4-
Dart & Flutter Packages by dev-cetera.com & contributors.
5-
6-
[![sponsor](https://img.shields.io/badge/sponsor-grey?logo=github-sponsors)](https://github.com/sponsors/dev-cetera)
7-
[![patreon](https://img.shields.io/badge/patreon-grey?logo=patreon)](https://www.patreon.com/c/RobertMollentze)
83
[![pub](https://img.shields.io/pub/v/df_router.svg)](https://pub.dev/packages/df_router)
9-
[![tag](https://img.shields.io/badge/tag-v0.4.15-purple?logo=github)](https://github.com/dev-cetera/df_router/tree/v0.4.15)
10-
[![license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/dev-cetera/df_router/main/LICENSE)
4+
[![tag](https://img.shields.io/badge/Tag-v0.4.15-purple?logo=github)](https://github.com/dev-cetera/df_router/tree/v0.4.15)
5+
[![buymeacoffee](https://img.shields.io/badge/Buy%20Me%20A%20Coffee-FFDD00?logo=buy-me-a-coffee&logoColor=black)](https://www.buymeacoffee.com/dev_cetera)
6+
[![sponsor](https://img.shields.io/badge/Sponsor-grey?logo=github-sponsors&logoColor=pink)](https://github.com/sponsors/dev-cetera)
7+
[![patreon](https://img.shields.io/badge/Patreon-grey?logo=patreon)](https://www.patreon.com/t0mb3rr)
8+
[![discord](https://img.shields.io/badge/Discord-5865F2?logo=discord&logoColor=white)](https://discord.gg/gEQ8y2nfyX)
9+
[![instagram](https://img.shields.io/badge/Instagram-E4405F?logo=instagram&logoColor=white)](https://www.instagram.com/dev_cetera/)
10+
[![license](https://img.shields.io/badge/License-MIT-blue.svg)](https://raw.githubusercontent.com/dev-cetera/df_router/main/LICENSE)
1111

1212
---
1313

14-
[![banner](https://github.com/dev-cetera/df_safer_dart/blob/v0.4.15/doc/assets/banner.png?raw=true)](https://github.com/dev-cetera)
15-
1614
<!-- BEGIN _README_CONTENT -->
1715

1816
## Summary
@@ -239,7 +237,7 @@ final requested = controller.requested;
239237

240238
---
241239

242-
☝️ Please refer to the [API reference](https://pub.dev/documentation/df_router/) for more information.
240+
🔍 For more information, refer to the [API reference](https://pub.dev/documentation/df_router/).
243241

244242
---
245243

@@ -249,7 +247,6 @@ This is an open-source project, and we warmly welcome contributions from everyon
249247

250248
### ☝️ Ways you can contribute
251249

252-
- **Buy me a coffee:** If you'd like to support the project financially, consider [buying me a coffee](https://www.buymeacoffee.com/dev_cetera). Your support helps cover the costs of development and keeps the project growing.
253250
- **Find us on Discord:** Feel free to ask questions and engage with the community here: https://discord.gg/gEQ8y2nfyX.
254251
- **Share your ideas:** Every perspective matters, and your ideas can spark innovation.
255252
- **Help others:** Engage with other users by offering advice, solutions, or troubleshooting assistance.
@@ -266,6 +263,7 @@ If you're enjoying this package and find it valuable, consider showing your appr
266263

267264
<a href="https://www.buymeacoffee.com/dev_cetera" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/default-orange.png" height="40"></a>
268265

269-
## 🧑‍⚖️ License
266+
## LICENSE
270267

271268
This project is released under the [MIT License](https://raw.githubusercontent.com/dev-cetera/df_router/main/LICENSE). See [LICENSE](https://raw.githubusercontent.com/dev-cetera/df_router/main/LICENSE) for more information.
269+

hosted_example/pubspec.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@ name: df_router_hosted_example
22
homepage: https://dev-cetera.com/
33
repository: https://github.com/robmllze/df_router
44
funding:
5+
- https://www.patreon.com/c/t0mb3rr
6+
- https://github.com/sponsors/t0mb3rr
57
- https://www.buymeacoffee.com/dev_cetera
6-
- https://www.patreon.com/c/RobertMollentze
7-
- https://github.com/sponsors/robmllze
8+
9+
810
publish_to: none
911
version: 0.1.0
1012
environment:

lib/src/_src.g.dart

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,17 @@
77
// ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
88
//.title~
99

10-
export './route_state.dart';
1110
export './prioritized_indexed_stack/animation_effect.dart';
11+
export './prioritized_indexed_stack/animation_effect_builder.dart';
1212
export './prioritized_indexed_stack/animation_layer_effect.dart';
13-
export './prioritized_indexed_stack/layer_effect_result.dart';
1413
export './prioritized_indexed_stack/effects.dart';
15-
export './prioritized_indexed_stack/animation_effect_builder.dart';
14+
export './prioritized_indexed_stack/layer_effect_result.dart';
1615
export './prioritized_indexed_stack/prioritized_indexed_stack.dart';
17-
export './route_manager.dart';
1816
export './route_builder.dart';
19-
export './route_controller.dart';
2017
export './route_contoller_provider.dart';
21-
export './route_widget_mixin.dart';
18+
export './route_controller.dart';
19+
export './route_manager.dart';
20+
export './route_state.dart';
2221
export './route_widget_builder.dart';
22+
export './route_widget_mixin.dart';
23+
export './stateful_route_manager.dart';
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
//.title
2+
// ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
3+
//
4+
// Copyright © dev-cetera.com & contributors.
5+
//
6+
// The use of this source code is governed by an MIT-style license described in
7+
// the LICENSE file located in this project's root directory.
8+
//
9+
// See: https://opensource.org/license/mit
10+
//
11+
// ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
12+
//.title~
13+
14+
import '/_common.dart';
15+
16+
// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
17+
18+
class StatefulRouteManager extends StatefulWidget {
19+
final RouteState Function()? initialRouteState;
20+
final RouteState Function() fallbackRouteState;
21+
final RouteState<Enum> Function()? errorState;
22+
final void Function(RouteController controller)? onControllerCreated;
23+
final List<RouteBuilder> builders;
24+
final bool clipToBounds;
25+
final TRouteWrapperFn? wrapper;
26+
27+
const StatefulRouteManager({
28+
super.key,
29+
this.initialRouteState,
30+
required this.fallbackRouteState,
31+
this.errorState,
32+
this.onControllerCreated,
33+
required this.builders,
34+
this.clipToBounds = false,
35+
this.wrapper,
36+
});
37+
38+
@override
39+
State<StatefulRouteManager> createState() => _StatefulRouteManagerState();
40+
}
41+
42+
class _StatefulRouteManagerState extends State<StatefulRouteManager> {
43+
late final RouteController _controller;
44+
45+
@override
46+
void initState() {
47+
super.initState();
48+
_controller = RouteController(
49+
initialRouteState: widget.initialRouteState,
50+
fallbackRouteState: widget.fallbackRouteState,
51+
errorRouteState: widget.errorState,
52+
builders: widget.builders,
53+
);
54+
widget.onControllerCreated?.call(_controller);
55+
}
56+
57+
@override
58+
Widget build(BuildContext context) {
59+
return RouteControllerProvider(
60+
controller: _controller,
61+
child: SyncPodBuilder(
62+
pod: Sync.okValue(_controller.pRouteState),
63+
cacheDuration: null,
64+
builder: (context, snapshot) {
65+
Widget child;
66+
UNSAFE:
67+
child = RepaintBoundary(
68+
child: _controller.buildScreen(
69+
context,
70+
snapshot.value.unwrap().unwrap(),
71+
),
72+
);
73+
if (widget.clipToBounds) {
74+
child = ClipRect(child: child);
75+
}
76+
return widget.wrapper?.call(context, child) ?? child;
77+
},
78+
),
79+
);
80+
}
81+
}

pubspec.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ name: df_router
1515
homepage: https://dev-cetera.com/
1616
repository: https://github.com/robmllze/df_router
1717
funding:
18+
- https://www.patreon.com/c/t0mb3rr
19+
- https://github.com/sponsors/t0mb3rr
1820
- https://www.buymeacoffee.com/dev_cetera
19-
- https://www.patreon.com/c/RobertMollentze
20-
- https://github.com/sponsors/robmllze
2121
description: A lightweight router designed for ease of use and efficient state management.
22-
version: 0.4.15
22+
version: 0.4.16
2323
topics:
2424
- router
2525
- navigation

0 commit comments

Comments
 (0)