Skip to content

Commit

Permalink
限制ToNote children类型
Browse files Browse the repository at this point in the history
  • Loading branch information
chen56 committed May 6, 2024
1 parent 13fbd9a commit b8b5231
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 20 deletions.
3 changes: 2 additions & 1 deletion packages/you_flutter/lib/src/note/note.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@ base class ToNote extends To {
NoteBuilder? page,
NoteBuilder? notFound,
NoteLayoutBuilder? layout,
super.children = const [],
List<ToNote> children = const [],
}) : super(
page: page == null ? null : (context) => _build(context, page),
notFound: notFound == null ? null : (context) => _build(context, notFound),
layout: layout == null ? null : (context, child) => layout(context, child as NoteMixin),
children: children,
);

static NoteMixin _build(BuildContext context, NoteBuilder page) {
Expand Down
39 changes: 20 additions & 19 deletions packages/you_flutter/lib/src/router.dart
Original file line number Diff line number Diff line change
Expand Up @@ -153,25 +153,6 @@ enum ToPartType {
/// To == go_router.GoRoute
/// 官方的go_router内部略显复杂,且没有我们想要的layout等功能,所以自定一个简化版的to_router
base class To {
/// part may be a template
/// /[user]/[repository]
/// - /dart-lang/sdk => {"user":"dart-lang","repository":"sdk"}
/// - /flutter/flutter => {"user":"flutter","repository":"flutter"}
@nonVirtual
final String part;

late final String _name;
late final ToPartType _type;

late To _parent = this;

@nonVirtual
final List<To> children;

final PageBodyBuilder? _page;
final PageBodyBuilder? _notFound;
final PageLayoutBuilder? _layout;

// TODO P1 root Node的part是routes,有问题!
To(
this.part, {
Expand All @@ -192,6 +173,26 @@ base class To {
}
}

/// part may be a template
/// /[user]/[repository]
/// - /dart-lang/sdk => {"user":"dart-lang","repository":"sdk"}
/// - /flutter/flutter => {"user":"flutter","repository":"flutter"}
@nonVirtual
final String part;

late final String _name;
late final ToPartType _type;

late To _parent = this;

@nonVirtual
final List<To> children;

final PageBodyBuilder? _page;
final PageBodyBuilder? _notFound;
final PageLayoutBuilder? _layout;

@nonVirtual
To get parent => _parent;

@nonVirtual
Expand Down

0 comments on commit b8b5231

Please sign in to comment.